← Return to documentation

Getting Started

We're so glad you want to use the API in your project! Here are the steps you'll want to follow:

  1. Get an API key
  2. Get data
  3. (help us) Get better

1. Get an API key

If you’re at an Abortion Access Hackathon, you should have already received an API key. This key will deactivate a few weeks after the hackathon, so if you’d like to keep your project online, please request a non-expiring API key.

To request a personal API key, fill out the form on the Request Access page. We’ll review your application and get back to you with the API key if you’re approved.

2. Get data

Here are a few examples of how to run queries in various languages. Complete code examples can be downloaded from the abortion-policy-api-examples Github repo.

cURL: get all waiting period information for zip code 30313

Run the following request in your console of choice:

curl -H 'token: YOUR_API_KEY' https://api.abortionpolicyapi.com/v1/waiting_periods/zips/30313

and you should see the following result:

    "counseling_waived_condition":"In cases of medical emergency."}

Note: if you want to run requests like this with the assistance of a GUI, we recommend Postman.

node.js: see if/when Medicaid can cover abortion in Alaska

Code snippet (complete code example on GitHub):

var rp = require('request-promise');

var apiKey = 'YOUR_API_KEY';

// Count the number of states that require parental consent for minors
    uri: 'https://api.abortionpolicyapi.com/v1/minors/states',
    method: 'GET',
    headers: { 'token': apiKey },
    json: true
}).then(function success(response) {
    if (response) {
        var states = Object.keys(response);
        var count = states.reduce((count, state) => {
            return count + (response[state].parental_consent_required == true); 
        }, 0);

        console.log(`Number of states that require parental consent: ${count}`);
}).catch(function error(response) {

after running this from the console, you should see something like:

Number of states that require parental consent: 26

Python: find all states that limit abortion at viability*

Code snippet (executable code example on GitHub):

import requests

apikey = 'YOUR_API_KEY'

url = 'https://api.abortionpolicyapi.com/v1/gestational_limits/states'
headers = { 'token': apikey }
r = requests.get(url, headers=headers)

states = r.json()

limit_at_viability = [state for state in states.keys() if states[state].get('banned_after_weeks_since_LMP') == 99]

message = f"The states that ban abortion at viability are: {', '.join(limit_at_viability)}"

after running this from the console, you should see something like:

The states that ban abortion at viability are: Arizona, California, Connecticut,
Delaware, District of Columbia, Hawaii, Idaho, Illinois, Maine, Maryland, Michigan,
Minnesota, Missouri, Montana, Tennessee, Utah, Washington, Wyoming

A Note About Rate Limits

The underlying database we’re using limits us to 5 requests/second. You may get a 429 error if you try to request data more rapidly than that. We will look into caching if this becomes an issue for our users.

3. (help us to) Get better

We’d love to hear from you. If you ever run into technical difficulties using the API, or if there are other ways to query the data that we should bundle into the backend, please let us know. Similarly, if you spot any errors, think there’s other information we should include, or have general feedback, please reach out. You can find us at hello@abortionpolicyapi.com .

What comes next

Here are the features we’re currently thinking of adding to the API. If there’s something else you’d like to see, please reach out!

  • /v1/summary/ return data from each table in a human-readable format

  • /v1/verbose/ include field reference documentation with each returned value

  • /v1/states/ stitch together data from all tables

  • /v1/changes/ allow tracking of how the laws have changed over time