Skip to content

API spec

LomaxRx edited this page Oct 12, 2018 · 23 revisions

Source


/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://d1y8sb8igg2f8e.cloudfront.net/images/shutterstock_763450642.2e16d0ba.fill-925x430.jpg"
        },
        "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://d1y8sb8igg2f8e.cloudfront.net/images/shutterstock_763450642.2e16d0ba.fill-32x15.jpg"
        }
      },
      ...
    ]
  },
  "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, press_release, quoted ) string
other_content_type_title filter by a programs custom content type string
category filter by category of custom content type(https://link_to_program_category_model_docs) string
topic_id id for a topic 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://d1y8sb8igg2f8e.cloudfront.net/images/shutterstock_294506222.2e16d0ba.fill-675x250.jpg",
              "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://d1y8sb8igg2f8e.cloudfront.net/images/shutterstock_294506222.2e16d0ba.fill-675x250.jpg",
      "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


/fellow


/report


/report/:reportId


/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>"
    },
    ...
  ]
}