phalt / swapi

*NOT MAINTAINED - NO GUARENTEE TO BE UP*
https://phalt.github.io/pokeapi-and-swapi-going-forward/
BSD 3-Clause "New" or "Revised" License
892 stars 507 forks source link

Films id does not match url id #140

Closed hazelbag closed 4 years ago

hazelbag commented 4 years ago

Hi, awesome API thanks. Though I believe there is an issue with the id and the film url id, I used this to learn nextjs and found that when navigating to the film with the id for instance "A New Hope" with the id of 4 using the url https://swapi.co/api/films/4/ I get "Phantom Menace" which has an id of 1.

phalt commented 4 years ago

The film_id has nothing to do with the resource ID. This is deliberate because it is supposed to help you understand that humans read numbers in patterns, but machines don't. If you're using this API properly, you should be using the url property to see how to access it.

Other examples of this: some people iterate through numbers 1-50 and get the ships, but some IDs are missing. Because humans thing in numbers incrementing by 1 each time, but machines don't necessarily. Read up on "Hypermedia as the engine of application state".