Skip to content

API spec

nmorduch edited this page Mar 17, 2022 · 23 revisions

newamericadotorg.api

Built with Django Rest Framework.

Resources


/program

function

returns list of all programs

parameters

none

returns

{
  "count": 16,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 14,
      "name": "Better Life Lab",
      "title": "Better Life Lab",
      "description": "...",
      "url": "/better-life-lab/",
      "logo": "",
      "slug": "better-life-lab",
      "subprograms": null,
      "subscriptions": [
        {
          "id": 20234,
          "title": "Better Life Lab Newsletters & Events",
          "ListID": "ac0721427fe250c9bfe10f98fa7fe725",
          "SegmentID": "Better Life Lab Newsletters & Events"
        }
      ]
    },
    ...
  ]
}

/subprogram

function

returns list of all subprograms

parameters

none

returns

{
  "count": 44,
  "next": "https://www.newamerica.org/api/subprogram/?page=2",
  "previous": null,
  "results": [
    {
      "id": 68,
      "name": "Better Banking Project",
      "url": "/economic-growth/better-banking-project/",
      "title": "Better Banking Project",
      "slug": "better-banking-project",
      "type": "Initiative"
    },
    ...
  ]
}

/program/:programId

function

returns details about program for use on program homepages

parameters

none

returns

{
  "id": 14,
  "name": "Better Life Lab",
  "title": "Better Life Lab",
  "story_grid": {
    "count": 9,
    "pages": [
      {
        "id": 21618,
        "title": "Sexual Harassment: A Severe and Pervasive Problem",
        "url": "/better-life-lab/reports/sexual-harassment-severe-and-pervasive-problem/",
        "slug": "sexual-harassment-severe-and-pervasive-problem",
        "content_type": {
          "id": 20138,
          "name": "Report",
          "title": "Reports",
          "api_name": "report",
          "url": "/better-life-lab/reports/",
          "slug": "reports"
        },
        "story_image": {
          "width": 925,
          "height": 430,
          "url": "https://..."
        },
        "story_excerpt": "...",
        "story_image_thumbnail": {
          "width": 32,
          "height": 15,
          "url": "https://..."
        }
      },
      ...
    ]
  },
  "description": "...",
  "url": "/better-life-lab/",
  "subprograms": null,
  "slug": "better-life-lab",
  "content_types": [
    {
      "id": 16,
      "url": "/better-life-lab/articles/",
      "slug": "articles",
      "title": "Articles",
      "api_name": "article",
      "name": "Article/Op-Ed"
    },
    ...
  ],
  "subpages": [
    {
      "id": 15,
      "slug": "global-gender-parity-initiative",
      "url": "/better-life-lab/global-gender-parity-initiative/",
      "title": "Global Gender Parity Initiative",
      "search_description": ""
    },
    ...
  ],
  "logo": "",
  "about": {
    "id": 21369,
    "url": "/better-life-lab/about/",
    "slug": "about",
    "body": "<div></div>",
    "title": "About Us",
    "subpages": [
      {
        "id": 21370,
        "url": "/better-life-lab/about/advisory-council/",
        "slug": "advisory-council",
        "body": "<div></div>",
        "title": "BLL Council"
      }
      ...
    ]
  },
  "subscriptions": [
    {
      "id": 20234,
      "title": "Better Life Lab Newsletters & Events",
      "ListID": "abcedfg",
      "SegmentID": "Better Life Lab Newsletters & Events"
    }
  ],
  "topics": true,
  "hide_subscription_card": false,
  "subscription_card_text": ""
}

/subprogram/:subprogramId

function

return subprogram details

parameters

none

returns

{
  "id": 17581,
  "name": "Humans of Cybersecurity",
  "story_grid": {
    "count": 6,
    "pages": [
      {
        "id": 20834,
        "title": "Colleges, It's Time for a General Technology Class",
        "url": "/cybersecurity-initiative/blog/colleges-its-time-general-technology-class/",
        "slug": "colleges-its-time-general-technology-class",
        "content_type": {
          "id": 42,
          "name": "Blog Post",
          "title": "Blog",
          "api_name": "blogpost",
          "url": "/cybersecurity-initiative/blog/",
          "slug": "blog"
        },
        "story_image": {
          "width": 925,
          "height": 430,
          "url": "https://..."
        },
        "story_excerpt": "We need to equip students of all disciplines with the skills to learn, analyze, and innovate in the world of digital technology.",
        "story_image_thumbnail": {
          "width": 32,
          "height": 15,
          "url": "https://..."
        }
      },
      ...
    ]
  },
  "parent_programs": [
    {
      "id": 39,
      "name": "Cybersecurity Initiative",
      "url": "/cybersecurity-initiative/",
      "slug": "cybersecurity-initiative",
      "title": "Cybersecurity Initiative"
    }
  ],
  "url": "/cybersecurity-initiative/humans-of-cybersecurity/",
  "slug": "humans-of-cybersecurity",
  "content_types": [
    {
      "id": 17605,
      "url": "/cybersecurity-initiative/humans-of-cybersecurity/blog/",
      "slug": "blog",
      "title": "#HumansOfCybersecurity Blog",
      "api_name": "blogpost",
      "name": "Blog Post"
    }
  ],
  "description": "...",
  "subpages": [
    {
      "id": 21423,
      "slug": "about",
      "url": "/cybersecurity-initiative/humans-of-cybersecurity/about/",
      "title": "About Us",
      "search_description": ""
    }
  ],
  "about": {
    "id": 21423,
    "url": "/cybersecurity-initiative/humans-of-cybersecurity/about/",
    "slug": "about",
    "body": "<div></div>",
    "title": "About Us",
    "subpages": [
      {
        "id": 21423,
        "url": "/cybersecurity-initiative/humans-of-cybersecurity/about/supage",
        "slug": "subpage",
        "body": "<div></div>",
        "title": "Subpage"
      },
      ...
    ]
  },
  "title": "Humans of Cybersecurity",
  "subscriptions": [
    {
      "id": 20252,
      "title": "Humans of Cybersecurity",
      "ListID": "ac0",
      "SegmentID": "Humans of Cybersecurity",
      "alternate_title": "Humans of Cybersecurity Newsletters & Events"
    },
    ...
  ],
  "hide_subscription_card": false,
  "subscription_card_text": ""
}

/post

function

returns list of posts

parameters

parameter description data type
id id of post integer
program_id id of program integer
subprogram_id id of subprogram integer
author_id id of author string
author_slug author slug string
after find posts after a given date (inclusive) date (YYYY-MM-DD)
before find posts before a given date (inclusive) date (YYYY-MM-DD)
content_type filter by content_type (report, blogpost, event, book, weeklyarticle, pressrelease, quoted ) string
other_content_type_title filter by a programs custom content type string
category filter by category of custom content type(https://github.com/newamericafoundation/newamerica-cms/wiki/Model-Reference#otherpostcategory) string
topic_id id for a topic integer
page_size limit number of results integer

returns

{
  "count": 2000,
  "next": "https://www.newamerica.org/api/post/?page=2&subprogram_id=131",
  "previous": null,
  "results": [
    {
      "id": 21894,
      "title": "New Spending Bill Boosts Funding for Key ECE Programs",
      "subheading": "Congress votes to increase funding of federal early care and education programs for fiscal year 2019",
      "date": "2018-10-08",
      "content_type": {
        "id": 61,
        "name": "Blog Post",
        "title": "EdCentral",
        "api_name": "blogpost",
        "url": "/education-policy/edcentral/",
        "slug": "edcentral"
      },
      "authors": [
        {
          "id": 146,
          "first_name": "Aaron",
          "last_name": "Loewenberg",
          "position": "Policy Analyst, Education Policy Program",
          "role": "Program Staff",
          "short_bio": "<p></p>",
          "profile_image": "https://...",
          "url": "/our-people/aaron-loewenberg/",
          "leadership": false,
          "full_name": "Aaron Loewenberg",
          "former": false,
          "expertise": [
            21185,
          ],
          "group": null
        }
      ],
      "programs": [
        {
          "id": 59,
          "name": "Education Policy",
          "url": "/education-policy/",
          "slug": "education-policy"
        }
      ],
      "subprograms": [
        {
          "id": 131,
          "name": "Early & Elementary Education",
          "url": "/education-policy/early-elementary-education-policy/",
          "slug": "early-elementary-education-policy"
        }
      ],
      "url": "/education-policy/edcentral/new-spending-bill-boosts-funding-key-ece-programs/",
      "story_excerpt": "...",
      "story_image": "https://...",
      "topics": [
        1537,
      ],
      "seo_title": ""
    },
    ...
    ]
  }

/event

function

returns list of events

parameters

parameter description data type
id id of post integer
program_id id of program integer
subprogram_id id of subprogram integer
program_slug slug of program string
time_period convenience param for finding all events before or after current date (future, past) string
after find posts after a given date (inclusive) date (YYYY-MM-DD)
before find posts before a given date (inclusive) date (YYYY-MM-DD)

returns

{
  "count": 4,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 13513,
      "title": "Lower Ed",
      "slug": "lower-ed",
      "date": "2017-02-27",
      "end_date": "2017-02-27",
      "start_time": "18:30:00",
      "end_time": "20:30:00",
      "street_address": "140 W 30th Street",
      "city": "New York",
      "state": "NY",
      "zipcode": "10001",
      "rsvp_link": "http://...",
      "story_image": "https://...",
      "programs": [
        {
          "id": 59,
          "name": "Education Policy",
          "url": "/education-policy/",
          "slug": "education-policy"
        },
        {
          "id": 1616,
          "name": "New America NYC",
          "url": "/nyc/",
          "slug": "nyc"
        }
      ],
      "subprograms": [
        {
          "id": 7469,
          "name": "Higher Education",
          "url": "/education-policy/higher-education/",
          "slug": "higher-education"
        }
      ],
      "url": "/nyc/events/lower-ed/",
      "story_excerpt": "...",
      "content_type": {
        "id": 2630,
        "name": "Event",
        "title": "Events",
        "api_name": "event",
        "url": "/nyc/events/",
        "slug": "events"
      },
      "seo_title": ""
    },
    ...
    ]
  }

/topic

function

returns all topics in its subtopic for a given program

parameters

parameter description data type
program_id id of program integer

return

{
  "count": 35,
  "next": null,
  "previous": "https://www.newamerica.org/api/topic/",
  "results": [
    {
      "id": 20228,
      "url": "/oti/topics/consumer-privacy/",
      "title": "Consumer Privacy",
      "slug": "consumer-privacy",
      "subtopics": [
        {
          "id": 20229,
          "url": "/oti/topics/consumer-privacy/broadband-privacy/",
          "title": "Broadband Privacy",
          "slug": "broadband-privacy",
          "subtopics": [
            ...
          ],
          "description": "...",
          "program": 87,
          "body": "<div></div>",
          "depth": 1,
          "featured_publications": [
            {
              "id": 18711,
              "title": "Open Technology Institute Publishes Model State Legislation for Broadband Privacy",
              "subheading": "",
              "date": "2017-10-30",
              "content_type": {
                "id": 92,
                "name": "Press Release",
                "title": "Press Releases",
                "api_name": "pressrelease",
                "url": "/oti/press-releases/",
                "slug": "press-releases"
              },
              "url": "/oti/press-releases/open-technology-institute-publishes-model-state-legislation-broadband-privacy/",
              "story_excerpt": "New America’s Open Technology Institute publishes model legislation to aid states in improving privacy protections for broadband customers.",
              "story_image": "https://...",
              "topics": [
                241,
                240
              ],
              "seo_title": ""
            },
            ...
          ]
        }
        ...
      ],
    }
    ...
  ]
}

/topic/:topicId

returns

{
  "id": 20228,
  "url": "/oti/topics/consumer-privacy/",
  "title": "Consumer Privacy",
  "slug": "consumer-privacy",
  "description": "As technology evolves, consumer privacy protections must evolve as well.",
  "body": "<div></div>",
  "seo_title": "",
  "depth": 0,
  "program": {
    "id": 87,
    "name": "Open Technology Institute",
    "url": "/oti/",
    "title": "Open Technology Institute",
    "slug": "oti",
    "type": "Initiative"
  },
  "featured_publications": [
    {
      "id": 18711,
      "title": "Open Technology Institute Publishes Model State Legislation for Broadband Privacy",
      "subheading": "",
      "date": "2017-10-30",
      "content_type": {
        "id": 92,
        "name": "Press Release",
        "title": "Press Releases",
        "api_name": "pressrelease",
        "url": "/oti/press-releases/",
        "slug": "press-releases"
      },
      "url": "/oti/press-releases/open-technology-institute-publishes-model-state-legislation-broadband-privacy/",
      "story_excerpt": "...",
      "story_image": "https://...",
      "topics": [
        241,
        240
      ],
      "subtopics": [
        {
          "id": 20229,
          "url": "/oti/topics/consumer-privacy/broadband-privacy/",
          "title": "Broadband Privacy",
          "slug": "broadband-privacy",
          "subtopics": [
            ...
          ],
          "description": null,
          "body": "<div></div>",
          "program": {
            "id": 87,
            "name": "Open Technology Institute",
            "url": "/oti/",
            "title": "Open Technology Institute",
            "slug": "oti",
            "type": "Initiative"
          },
          "depth": 1,
          "featured_publications": [
            ...
          ]
        }
      ],
    },
    ...
  ]
}

/author

function

return list of authors

parameters

parameter description data type
id id of post integer
slug id of post integer
program_id id of program integer
subprogram_id id of subprogram integer
role slug of program bool
leadership is author on leadership team string
topic_id id of topic author is expert in integer
former results filter out former staff by default, mark true to return former staff only bool
include_fellows include fellows in results bool

returns

  "count": 169,
  "next": "https://staging.newamerica.org/api/author/?page=2",
  "previous": null,
  "results": [
    {
      "id": 662,
      "first_name": "Kevin",
      "last_name": "Carey",
      "position": "Vice President, Education Policy and Knowledge Management",
      "role": "Program Staff",
      "short_bio": "<p></p>",
      "profile_image": "https://,,.jpg",
      "url": "/our-people/kevin-carey/",
      "leadership": true,
      "full_name": "Kevin Carey",
      "former": false,
      "expertise": [
        21189,
        ...
      ],
      "group": "()"
    },
    ...
  ]
}

/fellow

function

returns exclusively fellows

parameters

parameter description data type
id id of post integer
slug id of post integer
program_id id of program integer
subprogram_id id of subprogram integer
role slug of program bool
leadership is author on leadership team string
topic_id id of topic author is expert in integer
former results filter out former staff by default, mark true to return former staff only bool

return

"count": 218,
"next": "https://www.newamerica.org/api/fellow/?page=2",
"previous": null,
"results": [
  {
    "id": 12149,
    "first_name": "David",
    "last_name": "Abraham",
    "position": "Senior Fellow, Resource Security",
    "role": "Fellow",
    "short_bio": "<p><b>David Abraham</b> is a senior fellow in the Resource Security program at New America. </p>",
    "profile_image": "https://...",
    "url": "/our-people/david-abraham/",
    "leadership": false,
    "full_name": "David Abraham",
    "former": false,
    "expertise": [],
    "group": null
  },
  ...
 }
]

/report/:reportId

function

gets detail for a single report

parameters

none

returns

{
  "id": 21157,
  "title": "The Idealized Internet vs. Internet Realities (Version 1.0)",
  "subheading": "Analytical Framework for Assessing the Freedom, Openness, Interoperability, Security, and Resiliency of the Global Internet",
  "date": "2018-07-26",
  "content_type": {
    "id": 20268,
    "name": "Report",
    "title": "Reports",
    "api_name": "report",
    "url": "/cybersecurity-initiative/reports/",
    "slug": "reports"
  },
  "featured_sections": [

  ],
  "authors": [
    {
      "id": 973,
      "first_name": "Robert",
      "last_name": "Morgus",
      "position": "Sr. Policy Analyst, Cybersecurity Initiative and Deputy Director, FIU-New America C2B Partnership",
      "role": "Program Staff",
      "short_bio": "<p><b>Robert Morgus</b> is a senior policy analyst with New America’s Cybersecurity Initiative and International Security program and the deputy director of the FIU-New America C2B Partnership. <br/></p>",
      "profile_image": "https://na-staging.s3.amazonaws.com/images/robert-morgus_person_image.2e16d0ba.fill-200x200.jpg",
      "url": "/our-people/robert-morgus/",
      "leadership": false,
      "full_name": "Robert Morgus",
      "former": false,
      "expertise": [

      ],
      "group": null
    },
    {
      "id": 20729,
      "first_name": "Justin",
      "last_name": "Sherman",
      "position": "",
      "role": "External Author/Former Staff",
      "short_bio": "<p><b>Justin Sherman</b> is an intern with New America's Cybersecurity Initiative, researching Internet governance and working on the Humans of Cybersecurity project.</p>",
      "profile_image": "https://na-staging.s3.amazonaws.com/images/shermanheadshotcolor.2e16d0ba.fill-200x200.png",
      "url": "/our-people/justin-sherman/",
      "leadership": false,
      "full_name": "Justin Sherman",
      "former": false,
      "expertise": [

      ],
      "group": null
    }
  ],
  "programs": [
    {
      "id": 39,
      "name": "Cybersecurity Initiative",
      "url": "/cybersecurity-initiative/",
      "slug": "cybersecurity-initiative"
    }
  ],
  "subprograms": [

  ],
  "url": "/cybersecurity-initiative/reports/idealized-internet-vs-internet-realities/",
  "story_excerpt": "An analytical framework for assessing the freedom, openness, interoperability, security, and resiliency of the global internet.",
  "story_image": {
    "url": "https://na-staging.s3.amazonaws.com/images/shutterstock_736294369.2e16d0ba.fill-1300x630.jpg",
    "height": 486,
    "width": 1000,
    "source": "Shutterstock"
  },
  "topics": [

  ],
  "sections": [
    {
      "title": "Introduction",
      "hide_title": false,
      "number": 2,
      "slug": "introduction",
      "body": "<div></div>",
      "subsections": [
        {
          "title": "Subsection",
          "slug": "subsection",
          "url": "/cybersecurity-initiative/reports/idealized-internet-vs-internet-realities/analysis-tensions/#subsection"

        },
        ...
      ],
      "url": "/cybersecurity-initiative/reports/idealized-internet-vs-internet-realities/introduction"
    },
    ...
  ],
  "endnotes": [
    {
      "number": "1",
      "note": "<p>Network Reliability and Interoperability Council VI: Focus Group 3, “Network Interoperability,” 2003, https://transition.fcc.gov/nric/nric-6/fg3-report.pdf, 3.</p>"
    },
    ...
  ],
  "story_image_thumbnail": "https://...fill-30x14.jpg",
  "search_description": "",
  "data_project_external_script": null,
  "attachments": [
    {
      "title": "Downloadable file",
      "url": "https://...",
      "size": 10,
      "type": "PDF"
    },
    ...
  ],
  "acknowledgments": "<p></p>",
  "abstract": "<p></p>"
}

/weekly

function

returns list of all weekly editions

parameters

none

returns

{
  "count": 153,
  "next": "https://www.newamerica.org/api/weekly/?page=2",
  "previous": null,
  "results": [
    {
      "id": 21929,
      "slug": "edition-221",
      "number": "Edition 221",
      "url": "/weekly/edition-221/",
      "title": "The Weaponization of Social Media Is Transforming Politics",
      "story_image": "https://...",
      "story_excerpt": "..."
    },
    ...
  ]
}

/weekly/:weeklyId

function

returns detail for a weekly edition with all weekly articles

parameters

none

returns

{
  "id": 21929,
  "title": "The Weaponization of Social Media Is Transforming Politics",
  "search_description": "",
  "slug": "edition-221",
  "first_published_at": "2018-10-11T10:47:20.209360-04:00",
  "url": "/weekly/edition-221/",
  "number": "Edition 221",
  "articles": [
    {
      "id": 21933,
      "title": "Two Conservative Groups Are Suing Austin Over Its Nondiscrimination Ordinance",
      "date": "2018-10-11",
      "authors": [
        {
          "id": 21940,
          "first_name": "Matt",
          "last_name": "Zdun",
          "position": null,
          "role": "External Author/Former Staff",
          "short_bio": "<p><b>Matt Zdun</b> is a reporting fellow at <i>The Texas Tribune</i>.</p>",
          "profile_image": null,
          "url": "/our-people/matt-zdun/",
          "leadership": false,
          "full_name": "Matt Zdun",
          "former": false,
          "expertise": [

          ],
          "group": null
        }
      ],
      "body": "<div></div>",
      "story_image": "https://...",
      "slug": "two-conservative-groups-are-suing-austin-over-its-nondiscrimination-ordinance",
      "story_excerpt": "LGBTQ advocates say they're not worried.",
      "story_image_lg": "https://...",
      "story_image_sm": "https://...",
      "url": "/weekly/edition-221/two-conservative-groups-are-suing-austin-over-its-nondiscrimination-ordinance/",
      "post": "<div></div>"
    },
    ...
  ]
}

/jobs

function

returns list of jobs from jazz HR

parameters

none

returns

{
  "count": 0,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": "job_1234",
      "team_id": "",
      "title": "Program Assistant-Blockchain Trust Accelerator",
      "country_id": "United States",
      "city": "Washington",
      "state": "DC",
      "zip": "20005",
      "department": "Blockchain Trust Accelerator",
      "description": "<p></p>",
      "minimum_salary": "0",
      "maximum_salary": "0",
      "notes": "",
      "original_open_date": "2018-10-03",
      "type": "Full Time",
      "status": "Open",
      "send_to_job_boards": "Yes",
      "hiring_lead": "user_1234",
      "board_code": "LhG3hwyrD8",
      "internal_code": "",
      "questionnaire": "questionnaire_20120423175346_9MDY7L9QKWNNSTUP"
    },
    ...
  ]
}

/subscribe

function

POSTs a subscriber to Campaign Monitor with createsend-python.

A django csrf token must also be sent in the request's X-CSRFToken header. You can add the csrf tag to the Django template, then retrieve it with javascript

let csrf = null;
const csrfCookieMatch = document.cookie.match(/csrftoken=(.*?)(;|$)/)
if(csrfCookieMatch) csrf = csrfCookieMatch[1];

parameters

parameter description data type
g-recaptcha-response token from google's reCaptcha string
subscriptions[] name of subscriptions array
name string
email string
job_title string
org string
zipcode string

returns

if captcha verification failed:

{
  "response": "UNVERIFIED"
}

if verified but user data is invalid for campaign monitor:

{
  "response": "BAD_REQUEST"
}

if successful:

{
  "response": "OK"
}