Answer the question
In order to leave comments, you need to log in
What is the correct way to refer to related objects in REST API?
I can't figure out how to display related objects.
I looked through the GitHab API, made some conclusions, but it seemed to me not rational to implement them ...
Let's say there are 2 models.
Orders
{
"site_admin": false,
"name": "The Octocat",
"company": "GitHub",
"blog": "http://www.github.com/blog",
}
{
"id": 1,
"create_at": "2016-04-29T19:37:03Z",
"client": "client_ login",
"user": "root"
}
Answer the question
In order to leave comments, you need to log in
1. Why 100 requests? Let's say you want to ask for a list of all orders.
GET /api/v1/orders/
[{
"id": 1,
"created_time": "2016-04-29T19:37:03Z",
"client": "client_ login",
"employee": "jane"
}, {
"id": 2,
"created_time": "2016-05-29T19:37:03Z",
"client": "another_client",
"employee": "john"
}, ...]
GET /api/v1/clients/another_client/
{
"id": 1,
"created_time": "2016-04-29T19:37:03Z",
"full_name": "Vasya Pupkin",
"user": "bububum"
}
GET /api/v1/orders/
[{
"id": 1,
"created_time": "2016-04-29T19:37:03Z",
"client": {
"id": 2,
"full_name": "Vasya Pupkin"
},
"employee": "jane"
}, ...]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question