Skip to content
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

Get random thing (suggestion) #55

Closed
vladinator1000 opened this issue Jul 8, 2016 · 2 comments
Closed

Get random thing (suggestion) #55

vladinator1000 opened this issue Jul 8, 2016 · 2 comments

Comments

@vladinator1000
Copy link

vladinator1000 commented Jul 8, 2016

Hi folks, is it possible to get something like swapi.com/api/vehicles/random?

I'm making this app that gets a random thing by putting a random number in the url. (from 1 to the "count" of entries specified in the description of each endpoint) But sometimes I get a 404 errors.

For instance, there are 37 total vehicles, when I get a number in between, let's say 13, I get a 404 http://swapi.co/api/vehicles/13/

I would love to contribute but I only know Javascript :/

@phalt
Copy link
Owner

phalt commented Jul 8, 2016

@savovs IDs are not necessarily in order, they're just an identifier :)

I would suggest calling the endpoint to get a list of available resources, paginating through them, and storing the URL for each:

https://swapi.co/api/vehicles

Then your random function can be in your code.

Regarding your ability to contribute: you totally can! This project is intended to teach people, so don't feel that just because you've never written Python you can't help.

@vladinator1000
Copy link
Author

Awesome, thank you!

@phalt phalt closed this as completed Jul 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants