9

UPDATE: The government generously increased the API request limit to 1,000 per IP per hour. This question is now obsolete.


api.data.gov allows for up to 1,000 API requests per user per hour, which is plenty. However, each user requires their own API Key. How can I request a key for them without asking a user to register with api.data.gov?

The API I am using says:

"If you engineer your app to request a key for each user during your registration process – all they need is the users’ email, the app then acquires a key and stores it for use by the app. This then gives each instance of the app a rate limit of 1000/hr."

But they do not say how to create a key for those users.

The underlying technology is API Umbrella, but their documentation is not clear to me in programatically generating a key for users either.

How can I create a new key for each of my users, which could number in the thousands?

4

We have set a rate limit of 1000 requests/hr per IP rather than key. Our documentation now reflects this change.

5
+25

On the USDA Food Composition Database page you posted, there's a form to create an account via their website. That form submits a HTTP POST message to the following link:

https://api.data.gov/api-umbrella/v1/users.json?api_key=D8IbNeJvK7hjqvJ8hMzuAR5Gfl3FLF1YSiiAK0fy

(note the API key that's in this link is probably tied to the USDA's user creation privilege - this might change in the future)

If you submit a POST message with the following parameters, it should respond with an API key for that user (replacing "firstname", "lastname" and "user@example.com" with the appropriate fields for your users:

  • user[first_name]=firstname
  • user[last_name]=lastname
  • user[email]=user@example.com
  • user[use_description]
  • user[terms_and_conditions]=1
  • user[registration_source]=web
  • options[example_api_url]=https://api.data.gov/nrel/alt-fuel-stations/v1/nearest.json?api_key=____&location=Denver+CO
  • options[contact_url]=mailto:ndlinfo@ars.usda.gov
  • options[site_name]
  • options[send_welcome_email]=true
  • options[email_from_name]
  • options[email_from_address]
  • options[verify_email]=false

I'm not a lawyer either, so I don't know how legal this method is. You might be able to replace the USDA's API key "D8IbNeJvK7hjqvJ8hMzuAR5Gfl3FLF1YSiiAK0fy" with your API key if it doesn't work in the future.

EDIT: looking at an answer to this question, you might be able to make unauthenticated API requests to some US government APIs without a key, but usage limits are lower.

3

I've asked the team at api.data.gov to respond.

3

api.data.gov doesn't actually support end users programmatically creating API keys at this time. Sorry for the mixup (technically the API exists, as Anthony Joseph's answer points out, but this is only intended for federal agency partners right now). We'll followup in more detail with you and the USDA team via email about potential alternatives for higher rate limits.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.