Getting Started

+ code examples

Three simple steps

1. Request 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

A few examples of code are below. Check out our repository on Github for complete code examples.

3. Share feedback

Contact us if you:

  • have technical difficulties using the API

  • find other ways to query the data that we should bundle into the backend

  • spot any errors

  • have suggestions for additional 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.

Code examples

  • 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:

    { "Georgia":{ "waiting_period_hours":24, "counseling_visits":1, "counseling_waived_condition":"In cases of medical emergency."} }

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

  • Code snippet (executable 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

    rp({

    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);

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

    Number of states that require parental consent: 26

  • 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]

    limit_at_viability.sort()

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

    print(message)

    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 are working on improving this.