WhiteHouse / ndoch-hackathon

15 stars 14 forks source link

Feature: Ability to request multiple petitions (by id) in one request #17

Open BigSauce opened 11 years ago

BigSauce commented 11 years ago

I am developing an iOS app in which the user will watch/favorite many petitions. I need a way to request multiple petitions in one request for easier implementation and less network overhead on We the People's servers.

In my app, there is maintained a list of petition id's which the user is watching. I want to be able to specify multiple id's of the petitions I want in one API request. That way, I won't have to worry about exceeding my 10 request/second limit, and the We the People servers will not be bogged down with around 50 requests each time my users want to view their favorite petitions. Instead, one request would be sent.

An example request may look like the following: https://api.whitehouse.gov/v1/petitions.json?&id=1234&id=5678.

...or even https://api.whitehouse.gov/v1/petitions.json.&id=1234%205678

This functionality is critical to the performance of my app.

roberte3 commented 11 years ago

Big Sauce,

Rather than fighting with the API(And worse perhaps ATT's 2g edge network), there is a simpler way to get the information that you want and you can do it in two api calls (currently).

If you call this API https://api.whitehouse.gov/v1/petitions.json?limit=1000&offset=0 Right now the there are 1974 petitions out there so you will need to call it twice https://api.whitehouse.gov/v1/petitions.json?limit=1000&offset=1001

And cache that JSON inside of your app, and then query that with your petition IDs you can quickly determine the status

-

And because its all stored in your app data cache you can create your views in milliseconds rather than the tens of seconds on an ATT edge network in Alabama.

If you take a look at the source code to my iPhone app, https://github.com/roberte3/wethepeopleapp you can see how I implemented it using NSArrays stored to the disk, rather than using a SQLite database or coredata.

Feel free to little r me with any questions or if I can help out with your app.

-Rob roberte3@gmail.com

On Sat, Jun 22, 2013 at 11:32 AM, Big Sauce notifications@github.comwrote:

I am developing an iOS app in which the user will watch/favorite many petitions. I need a way to request multiple petitions in one request for easier implementation and less network overhead on We the People's servers.

In my app, there is maintained a list of petition id's which the user is watching. I want to be able to specify multiple id's of the petitions I want in one API request. That way, I won't have to worry about exceeding my 10 request/second limit, and the We the People servers will not be bogged down with around 50 requests each time my users want to view their favorite petitions. Instead, one request would be sent.

An example request may look like the following: https://api.whitehouse.gov/v1/petitions.json?&id=1234&id=5678.

...or even https://api.whitehouse.gov/v1/petitions.json.&id=1234%205678

This functionality is critical to the performance of my app.

— Reply to this email directly or view it on GitHubhttps://github.com/WhiteHouse/ndoch-hackathon/issues/17 .