layout | permalink |
---|---|
developer |
/developer/ |
This API is under active development, and breaking changes may be made without warning. Have feedback or questions? Please let us know!
Please note we have recently updated to `v1.1`, please update your requests accordingly.
</p>
In addition to being published and available for download, the data generated for this site is also available via an API.
Please note we have recently updated to v1.1
, please update your requests accordingly.
The URL for the API is https://api.gsa.gov/analytics/dap/v1.1
, and it exposes 3 routes to query data:
/reports/<report name>/data
/agencies/<agency name>/reports/<report name>/data
/domain/<domain>/reports/<report name>/data
To use the API, please register for an API key below and include it in your query in this fashion:
https://api.gsa.gov/analytics/dap/v1.1/reports/download/data?api_key=DEMO_KEY1
{% raw %}
// Enter the API key you signed up for and specially configured for this
// API key signup embed form.
apiKey: 'LQekm6CxhGGrjRGkBsZjJD4R0Rr8sKYRtX1ey4qX',
// Provide an example URL you want to show to users after they signup.
// This can be any API endpoint on your server, and you can use the
// special {{api_key}} variable to automatically substitute in the API
// key the user just signed up for.
exampleApiUrl: 'https://api.gsa.gov/analytics/dap/v1.1/reports/download/data?api_key={{api_key}}',
// OPTIONAL: Provide extra content to display on the signup confirmation
// page. This will be displayed below the user's API key and the example
// API URL are shown. HTML is allowed. Defaults to ""
// signupConfirmationMessage: '',
// OPTIONAL: Provide a URL to your own contact page to link to for user
// support. Defaults to "https://api.data.gov/contact/"
contactUrl: 'https://github.com/18F/analytics.usa.gov/issues',
// OPTIONAL: Set to true to verify the user's e-mail address by only
// sending them their API key via e-mail, and not displaying it on the
// signup confirmation web page. Defaults to false.
// verifyEmail: true,
// OPTIONAL: Set to false to disable sending a welcome e-mail to the
// user after signing up. Defaults to true.
// sendWelcomeEmail: false,
// OPTIONAL: Provide the name of your developer site. This will appear
// in the subject of the welcome e-mail as "Your {{siteName}} API key".
// Defaults to "api.data.gov".
// siteName: 'analytics.usa.gov',
// OPTIONAL: Provide a custom sender name for who the welcome email
// appears from. The actual address will be "noreply@api.data.gov", but
// this will change the name of the displayed sender in this fashion:
// "{{emailFromName}} <noreply@api.data.gov>". Defaults to "".
emailFromName: 'analytics.usa.gov',
// OPTIONAL: Provide an extra input field to ask for the user's website.
// Defaults to false.
// websiteInput: true,
// OPTIONAL: Provide an extra checkbox asking the user to agree to terms
// and conditions before signing up. Defaults to false.
// termsCheckbox: true,
// OPTIONAL: If the terms & conditions checkbox is enabled, link to this
// URL for your API's terms & conditions. Defaults to "".
// termsUrl: "https://agency.gov/api-terms/",
};
/* * * DON'T EDIT BELOW THIS LINE * * */ (function() { var apiUmbrella = document.createElement('script'); apiUmbrella.type = 'text/javascript'; apiUmbrella.async = true; apiUmbrella.src = 'https://api.data.gov/static/javascripts/signup_embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(apiUmbrella); })(); </script> Please enable JavaScript to signup for an api.data.gov API key.
{% endraw %}
The response represents the rows in the data
array in the JSON reports that can be downloaded, or the rows in the CSV files that can be downloaded. They are returned as an array of JSON objects. Here is an example of one such object:
{
"id": 60716,
"report_name": "today",
"report_agency": "justice",
"date_time": "2017-04-07T14:00:00.000Z",
"data": {
"visits": "4240"
},
"created_at": "2017-04-07T04:23:55.792Z",
"updated_at": "2017-04-07T04:23:55.792Z"
}
Note that is has the following properties:
id
: The primary key of the data pointreport_name
: The name of the data point's reportreport_agency
: The name of the data point's agencydate_time
: The data/time the data in the data point corresponds todata
: The data associated with the data point. This may contain child properties such as visits, browser, screen size, and so on, depending on the report
Reports can be queried by substituting <report name>
in the path with the name of the report.
The following reports can be queried using the API:
- download (example)
- traffic-source (example)
- device-model (example)
- domain (example)
- site (example)
- second-level-domain (example)
- language (example)
- os-browser (example)
- windows-browser (example)
- browser (example)
- windows-ie (example)
- os (example)
- windows (example)
- ie (example)
- device (example)
Reports can be queried by substituting <agency name>
in the path with the name of the agency. If the path without an agency name parameter is used, the reports correspond to government wide data.
The list of valid agency names includes:
- agency-international-development (example)
- agriculture (example)
- commerce (example)
- defense (example)
- education (example)
- energy (example)
- environmental-protection-agency (example)
- executive-office-president (example)
- general-services-administration (example)
- health-human-services (example)
- homeland-security (example)
- housing-urban-development (example)
- interior (example)
- justice (example)
- labor (example)
- national-aeronautics-space-administration (example)
- national-archives-records-administration (example)
- national-science-foundation (example)
- nuclear-regulatory-commission (example)
- office-personnel-management (example)
- postal-service (example)
- small-business-administration (example)
- social-security-administration (example)
- state (example)
- transportation (example)
- treasury (example)
- veterans-affairs (example)
For the site
, domain
, download
, and second-level-domain
reports you may use the domain
route, to only return results by domain.
The following query params are supported to work with the data:
limit
: Limit the number of data points that are rendered. The default is 1000 and the max is 10,000page
: Pages through the results. If the limit is set to1000
, usingpage=2
will render the 1001st through 2000th data point.after
: Limit the results to in dates on or after the date specified. ExpectsYYYY-MM-DD
.before
: Limit the results to in dates on or before the date specified. ExpectsYYYY-MM-DD
.