-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Endpoints #2
Comments
Continuing from #1....
I'm not sure I get this. The API endpoints are basically database queries, and serve the front end + anything that wants to use course data. The front-end serves webpages and ajax to web browsers. I think the concerns are independent. I think the API endpoints should focus on representing the data, and should think bigger than the catalogue website. Simpler Something else I've seen is a structure like a lot of Also kind of at-issue here is what the rest of the path looks like for individual course resources. Is a course id something like I suppose it comes back to whether we're striving for front/back URI consistency. I think |
I agree the what the frontend is going to do or how it's URLs are going to be structured should have no impact on the API. Sure, we're using the API to display course listings in a nice manner, but the API can be used for other things, including things that won't use the For an API I think the URLs should be descriptive as possible. For example This works when talking about getting a single, known object, but what about the case where you want to discover multiple objects (like all courses in ANAT)? What courses are in a subject is information that the subject should have so I would expect that the list of courses in a subject would just be a property of the subject, for example This structure also allows for greater granularity. For example, what if you only wanted to see the instructors for a course and didn't care about the time slots or anything else? For just getting a list of all objects of a type (like all subjects), another top level "folder" ( This API structure also leaves room for searching with For write requests ( Disclaimer: I've done some work on The Movie DB API (at http://docs.themoviedb.apiary.io/) so most of these suggestions come from it's structure. Examples:
|
I think something along these lines could work quite well. I think that we should have some discussion about what exactly will be visible at each endpoint, and I think that could lead to changes in this system, but it seems to make sense. |
Just for consideration, this site was one my work used to reference as "best practices". https://blog.apigee.com/detail/restful_api_design_can_your_api_give_developers_just_the_information Also as general intro to REST, this is a good webcast http://apigee.com/about/api-best-practices/restful-api-design-second-edition |
Summing up the discussion we had in person: Read operationsSelf links and IDs: We need to provide a link to the url that was access to return the data. This lets clients know where to post back to, among other things. The ID is needed so that clients can take the ID and use it to get more information about the object. The self link and the ID of the object will always be returned, with the only exception being for errors (a whole other thing). Pluralization: We need to stick to either plural or not. Since getting back a single object from a plural endpoint makes more sense than getting back multiple objects from a singular endpoint, we decided that plural was best. The Bare endpoints: Bare endpoints are the endpoints that don't have a specific ID attached to them. Because of the lack of ID, they return all the objects of that type. Because this is typically a lot of data, we wouldn't allow expansion on bare endpoints, only regular fields. Fields that are objects will return the ID of the object to be used in future lookups. Sections: Based on trawling through SOLUS, we came to the conclusion that sections are unique objects that don't have to be tied to a single course. Sections can also be combined with other sections. For this reason, we should include an endpoint specific to them ( Batch queries: We have to include the case where you want some sort of data on 20 objects, but only have the IDs. Instead of doing 20 requests, we should include some way of getting a certain piece of data out of a specified subset. This has been added on to the "bare endpoint" by allowing the client to pass a list of ids into the query. Batch queries should be limited to a certain number of objects per lookup (100?). Pagination: The API needs to be able to paginate data. For pagination, we decided to use the limit/offset approach, where the limit defines how many objects to return, while the offset is the object number to start at. Since all IDs will be strings, sorting alphabetically will keep the order constant. Limiting will only take effect on queries to bare endpoints and searches since specific objects will only return a single object. Specific objects
Bare endpoints
Write operationsNo write operations on queries with expanded fields (what would they do?). On bare endpoints (
On individual endpoints (
Everything else would be an error Examples
|
A place to discuss the REST endpoitns of the qcumber-api. Building off the discussion from #1.
The text was updated successfully, but these errors were encountered: