Code Monkey home page Code Monkey logo

public_api_specs's Introduction

NYT Public API Specs

The API Specs (in OpenAPI format, formerly Swagger) for the APIs available from developer.nytimes.com.

Learn more about OpenAPI at openapis.org.

Checkout developer.nytimes.com for all of the documentation about using NYTimes APIs and to signup for an API Key.

Questions? Email us at [email protected] or open an issue.

If you notice any issues with the specs or want to contribute improvements, pull requests are welcome!

public_api_specs's People

Contributors

dperjar avatar hossain-khan avatar ivangoncharov avatar jhigginbotham avatar nyt-hughmandeville avatar scottefein avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

public_api_specs's Issues

Archive API Requests Returning Partial Responses

Hello, and happy 4th of July 🎆🇺🇸🎆

I'm hacking on the Archive API, and am running into some behavior I wasn't expecting.

In my node script, I send two requests for two different month's worth of data, three seconds apart. I'm using the request-promise library to issue the requests. Sometimes these will complete successfully, but often they will not.

Specifically, the response will come back with a 200 status code, but the JSON body will be incomplete.

I was able to replicate this behavior using Charles, making back-to-back queries for February 1985, over 30 seconds apart.

Here are gists representing the first complete response, and the second partial response.

My main questions are:

  • Is there a problem with the format of the requests I'm sending to the API?
  • Is there a best practice I should follow to both format the requests and process the response, so that I could either stop getting partial responses or limit the chances that a partial response would be returned?

Thanks and please let me know if there are additional details I can provide.

No response/403 for specifically paginated requests

Hi,

The following request gives no response (I've curl-ed and gone through the python requests library):
https://api.nytimes.com/svc/search/v2/articlesearch.json?fq=persons%3A%28%22Obama%2C+Barack%22%29&page=11&api-key=xxxx

The following request gives an html "403 forbidden" response:
https://api.nytimes.com/svc/search/v2/articlesearch.json?fq=persons%3A%28%22Trump%2C+Donald+J%22%29&page=12&api-key=xxxx

The following requests give valid, seemingly correct json responses:
https://api.nytimes.com/svc/search/v2/articlesearch.json?fq=persons%3A%28%22Trump%2C+Donald+J%22%29&page=11&api-key=xxxx

https://api.nytimes.com/svc/search/v2/articlesearch.json?fq=persons%3A%28%22Trump%2C+Donald+J%22%29&page=13&api-key=xxxx

https://api.nytimes.com/svc/search/v2/articlesearch.json?fq=persons%3A%28%22Obama%2C+Barack%22%29&page=10&api-key=xxxx

https://api.nytimes.com/svc/search/v2/articlesearch.json?fq=persons%3A%28%22Obama%2C+Barack%22%29&page=12&api-key=xxxx

In other words, the 11th page of fq=persons:("Obama, Barack") returns nothing (despite the 10th and 13th returning correct results), and the 12th page of fq=persons:("Trump, Donald J") returns a 403 Forbidden page (despite the 11th and 13th returning correct results).

A friend tried this on his computer with a different api key and got the same results.

Any ideas on what's going on?

Is there a user dashboard?

Great work, love the design and the public spec; main immediate question: is there an endpoint for a logged-in user to get the API keys they've already signed up for?

Could not create app

Hello,

I'm trying to create an App and get an API key, but when I click "create", it shows "App could not be created." I wonder how I can create an App. I only enabled the Archive API.

Many thanks!

APi works wrong with encoded form ("%2B") for "+" character.

Steps to reproduce:

  1. Perform GET request to http://api.nytimes.com/svc/mostpopular/v2/mostemailed/Smarter%2BLiving/30.json
  2. Check response

Expected result: correct answer as we received with:
http://api.nytimes.com/svc/mostpopular/v2/mostemailed/Smarter%20Living/30.json
http://api.nytimes.com/svc/mostpopular/v2/mostemailed/Smarter Living/30.json
http://api.nytimes.com/svc/mostpopular/v2/mostemailed/Smarter+Living/30.json

Actual result:
{
"status": "OK",
"copyright": "Copyright (c) 2018 The New York Times Company. All Rights Reserved.",
"num_results": 0,
"results": []
}

Article serach API how to get URL for image for each article

How to get Url for image source of each article in Article search API
https://api.nytimes.com/svc/search/v2/articlesearch.json?api-key=&q=sometext&page=0

In this API hit it returns a "multimedia" [object] which contain attribute -->
"url": "images/2016/12/14/us/14zinke/00zinke-thumbStandard.jpg"

I tried to append this url with base url and web_url as well, not able to get the image.
Just wondering how can I download image for each article here?

Archive missing September and October 1978

Dear NYTimes API developers,

The archive API returns zero hits for the months of September and October 1978. Below I paste the calls and responses that I got, which work normally for any other month in the archive:

Call: https://api.nytimes.com/svc/archive/v1/1978/10.json
Response: {"copyright":"Copyright (c) 2013 The New York Times Company. All Rights Reserved.","response":{"meta":{"hits":0},"docs":[]}}

Call: https://api.nytimes.com/svc/archive/v1/1978/9.json
Response:{"copyright":"Copyright (c) 2013 The New York Times Company. All Rights Reserved.","response":{"meta":{"hits":0},"docs":[]}}

Is the NYT archive really empty those two months or is there any issue I'm missing?

Best regards,
David Garcia

Incoherent Type on Empty Media tag

When Media tag is empty its returning an empty String instead of an empty array.

http://api.nytimes.com/svc/mostpopular/v2/mostviewed/all-sections/7.json?apikey=XYZ

{
"url":"https://www.nytimes.com/2018/05/17/style/royal-wedding-time-date.html",
"adx_keywords":"Royal Wedding;Weddings and Engagements;Time;Harry, Prince of Wales;Markle, Meghan",
"column":null,
"section":"Style",
"byline":"By THE NEW YORK TIMES",
"type":"Article",
"title":"What Time Was the Royal Wedding in My Time Zone?",
"abstract":"Interesting news: The royal wedding is now in the past. ",
"published_date":"2018-05-17",
"source":"The New York Times",
"id":100000005904642,
"asset_id":100000005904642,
"views":4,
"des_facet":[
"WEDDINGS AND ENGAGEMENTS",
"TIME"
],
"org_facet":"",
"per_facet":[
"HARRY, PRINCE OF WALES",
"MARKLE, MEGHAN"
],
"geo_facet":"",
"media":""
},

Linked Open Data portal down ?

Hi,

The Linked Open Data portal at http://data.nytimes.com referenced in the Semantic API documentation appears to be down.
The documentation contains examples like http://data.nytimes.com/47452218948077706853, which is not responding, but even the base URL that should supposedly give access to the vocabulary also seems to be down.

Is this by design or will this data return at some point ?

Thanks !

Geo API Query Problems

I'm having some issues querying the Geo API and am wondering if someone can provide me an example or let me know what I am doing incorrectly. I would like to query articles originating from a specific distance from lat/long location OR query a bounding box.

If I enter the query URI in the browser bar, as such: http://api.nytimes.com/svc/semantic/v2/geocodes/query.json?nearby=38.920833,-94.622222&api-key=MY_KEY, I get:

{
"status": "ERROR",
"copyright": "Copyright (c) 2015 The New York Times Company. All Rights Reserved.",
"errors": ["global name \u0027lat\u0027 is not defined"],
"results": []
}

If I use the API Builder, I get the following, regardless of whether I provide a filter.
{
"status": "ERROR",
"copyright": "Copyright (c) 2015 The New York Times Company. All Rights Reserved.",
"errors": [
"Specify at least one filter"
],
"results": []
}

Thanks for any help you can provide!

Score attribute

When I use article search it returns "score" and sometimes I get two records that are identical except for differing "score" values. Is this expected behavior or unexpected? I don't see score mentioned in any of the documents. (I'm assuming it's a relevancy score of some kind.)

Using Semantic API for getting descriptors and taxonomies for an article

I'm interested in getting all the taxonomies and descriptors for specific articles.
Trying this request:
http://api.nytimes.com/svc/semantic/v2/concept/article/2010/09/30/energy-environment/30safety.json?fields=all&api-key=xxx
from the documentation returns the following response:

<!DOCTYPE` HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.</p>

What would be the right way to query for an article semantic features?

web_url returning incomplete urls?

Hi,

You were super-prompt responding to my last question so first of all, thanks!

I'm making a request like the one generated by the api console below:

var url = "https://api.nytimes.com/svc/search/v2/articlesearch.json";
url += '?' + $.param({
  'api-key': "232c8759b11f4986bcef2e33a31fb713",
  'fq': "persons:(\"Obama, Barack\")",
  'begin_date': "20090808",
  'end_date': "20090815",
  'page': 4
});
$.ajax({
  url: url,
  method: 'GET',
}).done(function(result) {
  console.log(result);
}).fail(function(err) {
  throw err;
});

One of the results returned includes the field "web_url": "/data/daily/2009/08/11/376388.sgml" Based on the other fields, it looks like this article is the same as the article at http://query.nytimes.com/gst/fullpage.html?res=940DE4D9113AF932A2575BC0A96F9C8B63. Is there a way for me to get the second url (which I can actually get to) given the first?

Thanks!

Community (recent.json) not returning JSON

I got my new API key and tested (using the API Console) 'Recent Comments' under the Community API, which is used in my app. The response is script and HTML instead of JSON. I have the response posted below:

<title>Help - The New York Times</title> <script type="text/javascript" src="http://graphics8.nytimes.com/js/common.js"></script> <script type="text/javascript" src="http://graphics8.nytimes.com/js/common/screen/DropDown.js"></script> <script type="text/javascript" src="http://graphics8.nytimes.com/js/util/tooltip.js"></script>
    Campaign ID: 283562 | Creative: 2_inyt2016_bar1_digi_may_sale_64XLF -- 413258 | Page: www.nytimes.com/content/help/error.html / Targeted Page: www.nytimes.com | Position: Bar1 <style> @import url(https://a1.nyt.com/fonts/css/fonts.css);.font-smoothing{-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;}.NYT5Style .masthead-tools #bar1-singlepanel{display: inline; vertical-align: top;}.NYT5Style .masthead-tools{padding: 0}#bar1-singlepanel{border: none; position: relative;}.bar1_hover{opacity: 0;}.sub_small_hide{display: none;}#bar1-singlepanel > a{background-color: #6288A5; border: 1px solid #4D7B9F; border-radius: 3px; color: #fff !important; display: inline-block; font-family: franklin-normal-700, sans-serif; font-style: normal; font-weight: 700; font-size: 1em; padding: 7px 10px 6px; text-transform: uppercase; text-decoration: none;-moz-box-sizing: border-box;line-height: 13px;}#bar1-singlepanel > a:hover{background-color: #326891; border: 1px solid #265E8B; text-decoration: none;}#hovercard{width: 450px; height: 330px; display: none; margin-left: -360px; z-index: 1000000152; border: 0; position: absolute; left: 50%; top: 30px; text-align: left; -moz-box-shadow: 0 0 5px #888; -webkit-box-shadow: 0 0 5px #888; box-shadow: 0 0 5px #888; white-space: normal; background: #e0de7b url('http://graphics8.nytimes.com/adx/images/ADS/41/32/ad.413258/bg-bar1.png') 0 0 no-repeat;}#bar1-headline{position: absolute; top: 76px; left: 31px; font-family: karnak-normal-400, sans-serif; font-style: normal; font-weight: 400; font-size: 25px; line-height: 26px; color: #fff; font-weight: 100; width: 300px; text-align: left;}#bar1-headline span{color: #0ea587;}#bar1-subhead{position: absolute; top: 130px; left: 31px; color: #555556; font-family: franklin-normal-700, sans-serif; font-style: normal; font-weight: 700; font-size: 34px; line-height: 30px; width: 300px; text-align: left;}#bar1-cta{font-family: franklin-normal-700, sans-serif; font-style: normal; font-weight: 700; position: absolute; top: 262px; right: 27px; width: 80px; height: 30px; background: #fff; font-size: 11px; line-height: 13px; padding: 0; text-align: center; text-decoration: none; border-radius: 3px;}#bar1-cta a{display: block; height: 100%; cursor: pointer; color: #000; text-decoration: none; text-transform: uppercase; border: 0px; padding-top: 9px;}#hovercard:after{bottom: 100%; left: 350px; border: solid transparent; content: " "; width: 0; height: 0; position: absolute; pointer-events: none; border-bottom-color: #e0de7b; border-width: 8px; margin: 0;}.NYT5Style #hovercard{top: 18px;}.NYT5Style #hovercard a:hover{background-color: #414042;}/* WEBKIT ONLY RULES */@media screen and (-webkit-min-device-pixel-ratio:0){.NYT5Style #hovercard{top: 28px !important; margin-left: -283px;}.NYT5Style #hovercard:after{left: 273px;}}/* EXCLUDING NYT4 INTERACTIVES */#interactiveABC #bar1-singlepanel{display: none;} .ad.bar1-ad .user-subscriptions-group { display: inline; }

    .bar1-hidden {
    margin-left: 8px;
    }
    </style>

    • 1 of 10 articles read
    • Subscribe Now
          <div id="hovercard" class="font-smoothing" data-campaign-name="inyt2016_bar1_digi_may_sale_64XLF">
              <div id="bar1-body">
                  <div id="bar1-headline">The Digital Sale<br><span>Ends Today</span></div>
                  <div id="bar1-subhead"><b>One Year. 60% off.<br>Unlimited Access.</b></div>
                  <div id="bar1-cta"><a href="http://www.nytimes.com/adx/bin/adx_click.html?type=goto&opzn&page=www.nytimes.com&pos=Bar1&sn2=2fe14a5/d7f7f24f&sn1=538bded0/743577ed&camp=inyt2016_bar1_digi_may_sale_64XLF&ad=2_inyt2016_bar1_digi_may_sale_64XLF&goto=http%3A%2F%2Finternational%2Enytimes%2Ecom%2Fsubscriptions%2Finyt%2Flp8U87X%2Ehtml%3Fadxc%3D283562%26adxa%3D413258%26page%3Dwww.nytimes.com%26pos%3DBar1%26campaignId%3D64XLF" target="_blank">Save now</a></div>
              </div>
          </div>
      
    Subscribe <script src="http://graphics8.nytimes.com/marketing/ADX/bar1/bar1_meter_count_v2.js"></script>
  • Help

</NYT_DYNAMIC_IFADS>

Search All NYTimes.com

</NYT_GLOBAL_EDITION_BRANDING_SF>

<NYT_GLOBAL_EDITION_LOGO_SF>

Help

</NYT_GLOBAL_EDITION_LOGO_SF>

We're Sorry

An error has occurred. Please try again later or contact Customer Service for assistance.

Search Help

</NYT_DYNAMIC_IFADS>

<script language="JavaScript" type="text/javascript"> NYTD.require('http://graphics8.nytimes.com/js/app/sitehelp/toggleDialogBoxes.js'); </script> <script type="text/javascript" language="JavaScript"> NYTD.siteHelp.toggleDialogBoxes(); </script>

</NYT_DYNAMIC_IFADS>
<NYT_DYNAMIC_IFADS Bottom8>

</NYT_DYNAMIC_IFADS>
<NYT_DYNAMIC_IFADS Bottom9>

</NYT_DYNAMIC_IFADS>
<NYT_DYNAMIC_IFADS Inv1>

</NYT_DYNAMIC_IFADS>
<NYT_DYNAMIC_IFADS Inv2>

</NYT_DYNAMIC_IFADS>
<NYT_DYNAMIC_IFADS Inv3>

</NYT_DYNAMIC_IFADS>
<NYT_DYNAMIC_IFADS ADX_CLIENTSIDE>

</NYT_DYNAMIC_IFADS>

    <!-- Start UPT call -->
    <img height="1" width="3" border=0 src="http://up.nytimes.com/?d=0//&t=6&s=0&ui=&r=http%3a%2f%2fwww%2enytimes%2ecom%2fref%2fmembercenter%2fapperror%2ehtml&u=www%2enytimes%2ecom%2fcontent%2fhelp%2ferror%2ehtml%3f">
    <!-- End UPT call -->

    
    <script language="JavaScript"><!--
      var dcsvid="";
      var regstatus="non-registered";
    //--></script>
    <script src="http://graphics8.nytimes.com/js/app/analytics/trackingTags_v1.1.js" type="text/javascript"></script>
    <noscript>
      <div><img alt="DCSIMG" id="DCSIMG" width="1" height="1" src="http://wt.o.nytimes.com/dcsym57yw10000s1s8g0boozt_9t1x/njs.gif?dcsuri=/nojavascript&amp;WT.js=No&amp;WT.tv=1.0.7"/></div>
    </noscript>

[Movie Review API] publication-date params don't work

It seems that the params for publication-date in the Movies API /search.json route are completely ineffective, even in the online Swagger tester.

Example:
https://api.nytimes.com/svc/movies/v2/reviews/search.json?&publication-date=2001-01-01;2001-01-31&api-key=<SOME_KEY>

For me, this always returns the most recent reviews, no matter what date ranges I include.

Several API spec discrepancies

Hello,

Thanks for making these API specs publicly available.

I have found several discrepancies between the API specs available in this repo and those served from the developer portal. For example, comparing the article search api spec here and a parsed snapshot of the one served from the developer portal:

There are many diffs -- the one in this repo appears to be v1. Can I assume that the specs served from the developer portal are the source of truth? Cursory testing seems to indicate this. If this is the case I would be happy to make some PRs to update the specs here.

Thanks for your time.

[Article Search API] Data inconsistency

Hi !

I was trying to access to the Article Search API but when I tried to parse the response, I encountered some inconsistency in the data :

{
  "response": {
    "docs": [
      {
        "web_url": "http://www.nytimes.com/2016/06/15/t-magazine/fashion/duro-olowu-dress-ritual.html",
        "byline": {
          "person": [
            {
              "organization": "",
              "role": "reported",
              "firstname": "Aimee",
              "rank": 1,
              "lastname": "FARRELL"
            }
          ],
          "original": "By AIMEE FARRELL"
        },
        "type_of_material": "News",
        "_id": "5761930938f0d81a0f68f3e0",
        ....
      },
      {
        "web_url": "http://www.nytimes.com/slideshow/2016/07/10/travel/exploring-the-alsace-region-of-europe.html",
        "byline": [],
        "type_of_material": "Slideshow",
        "_id": "577d07ea38f0d849682ddd8d",
        ....
      },
      ....
    ]
  }
}

As you can see, in the first article, the byline field is an object, while it's an array in the second one. Is that an actual issue ? Or is it done on purpose ?

Article search by category

Hello,

I am having difficulty determining how to conduct an Article search by topic/category. I would think this would be more straight forward, to provide a 'category' or 'topic' parameter, but I can't seem to find an explanation for this type of search in the documentation. Any help is greatly appreciated!

Thank you!

Section ID List

First of all, thank you for the open API. It has been really nice to use real data in my first internship project.

However, I did notice a problem with your section identification for the Most Popular API. The "sections-list" call returns section names, but no IDs.

Initially I thought those were easily convertible to their respective IDs, but that is not the case. For example, "Business Day" is associated with the section ID "business" and in some cases, like "U.S.", it seems impossible to find the corresponding ID (e.g. U.S./US/us/... do not work).

Is there a way to find all available IDs, possibly even included in the "sections-list" call?

Top Stories API Response: Different object types

When I am trying to parse the object from Top stories API. There are different types for:
"org_facet"
"per_facet"
"geo_facet"
"multimedia"

When the fields are empty the type is a string no is an array. It causes and error when I m trying to parse the json object:

Example:

Not empty
"org_facet": ["Islamic State in Iraq and Syria (ISIS)"]

Empty
"org_facet":""

Postman Collection

What would it take to get your OpenAPI imported into Postman and published as a collection to the Postman API Network? https://explore.postman.com/ -- so that it can searchable in the product, and imported with a single click?

HTTP 500 error, specific term on specific dates.

Querying 'flu' in the Article Search API over some specific dates (for example, 2009/09/16 or 2009/08/15) leads invariably to a 500 HTTP error:

{
"timestamp": 1502585460212,
"status": 500,
"error": "Internal Server Error",
"exception": "org.springframework.core.convert.ConversionFailedException",
"message": "Failed to convert from type [java.lang.String] to type [java.net.URL] for value '/data/daily/2009/09/16/147800.sgml'; nested exception is java.net.MalformedURLException: no protocol: /data/daily/2009/09/16/147800.sgml",
"path": "/svc/add/v1/articlesearch.json"
}

Encoding issue?

Looks like some characters are not being properly encoded, check the output for https://api.nytimes.com/svc/topstories/v2/home.json
I tested this on the https://developer.nytimes.com/docs/top-stories-product/1/routes/%7Bsection%7D.json/get page to be sure it wasn't something on my side and I am seeing the same thing.

Here is the current results, note the title of the first article:

{
  "status": "OK",
  "copyright": "Copyright (c) 2019 The New York Times Company. All Rights Reserved.",
  "section": "home",
  "last_updated": "2019-03-07T08:37:03-05:00",
  "num_results": 40,
  "results": [
    {
      "section": "U.S.",
      "subsection": "Politics",
      "title": "In Blow to Trump, America���s Trade Deficit in Goods Hits Record $891 Billion",
      "abstract": "The president has railed against the trade deficit, but numbers from last year show that textbook economics caught up with some of his unorthodox economic policies.",
      "url": "https://www.nytimes.com/2019/03/06/us/politics/us-trade-deficit.html",
      "byline": "By JIM TANKERSLEY and ANA SWANSON",
      "item_type": "Article",
      "updated_date": "2019-03-06T18:15:36-05:00",
      "created_date": "2019-03-06T09:28:17-05:00",
      "published_date": "2019-03-06T09:28:17-05:00",
      "material_type_facet": "",
      "kicker": "",
      "des_facet": [
        "International Trade and World Market",
        "United States Politics and Government",
        "United States International Relations",
        "United States Economy",
        "Customs (Tariff)"
      ],
      "org_facet": [],
      "per_facet": [
        "Trump, Donald J"
      ],
      "geo_facet": [
        "China"
      ],
      "multimedia": [
        {
          "url": "https://static01.nyt.com/images/2019/03/06/reader-center/06dc-deficit-hp/06dc-deficit-hp-thumbStandard.jpg",
          "format": "Standard Thumbnail",
          "height": 75,
          "width": 75,
          "type": "image",
          "subtype": "photo",
          "caption": "The United States trade deficit in goods reached $891.3 billion in 2018 — the highest it’s ever been.",
          "copyright": "Justin Sullivan/Getty Images"
        },
        {
          "url": "https://static01.nyt.com/images/2019/03/06/reader-center/06dc-deficit-hp/06dc-deficit-hp-thumbLarge.jpg",
          "format": "thumbLarge",
          "height": 150,
          "width": 150,
          "type": "image",
          "subtype": "photo",
          "caption": "The United States trade deficit in goods reached $891.3 billion in 2018 — the highest it’s ever been.",
          "copyright": "Justin Sullivan/Getty Images"
        },
        {
          "url": "https://static01.nyt.com/images/2019/03/06/reader-center/06dc-deficit-hp/merlin_151712013_85331bd1-75cc-4617-ae04-8ac94ef85989-articleInline.jpg",
          "format": "Normal",
          "height": 124,
          "width": 190,
          "type": "image",
          "subtype": "photo",
          "caption": "The United States trade deficit in goods reached $891.3 billion in 2018 — the highest it’s ever been.",
          "copyright": "Justin Sullivan/Getty Images"
        },
        {
          "url": "https://static01.nyt.com/images/2019/03/06/reader-center/06dc-deficit-hp/06dc-deficit-hp-mediumThreeByTwo210.jpg",
          "format": "mediumThreeByTwo210",
          "height": 140,
          "width": 210,
          "type": "image",
          "subtype": "photo",
          "caption": "The United States trade deficit in goods reached $891.3 billion in 2018 — the highest it’s ever been.",
          "copyright": "Justin Sullivan/Getty Images"
        },
        {
          "url": "https://static01.nyt.com/images/2019/03/06/reader-center/06dc-deficit-hp/merlin_151712013_85331bd1-75cc-4617-ae04-8ac94ef85989-superJumbo.jpg",
          "format": "superJumbo",
          "height": 1332,
          "width": 2048,
          "type": "image",
          "subtype": "photo",
          "caption": "The United States trade deficit in goods reached $891.3 billion in 2018 — the highest it’s ever been.",
          "copyright": "Justin Sullivan/Getty Images"
        }
      ],
      "short_url": "https://nyti.ms/2TzXX9H"
    },
    {
      "section": "Business",
      "subsection": "",
      "title": "Regulators Move to Ease Post-Crisis Oversight of Wall Street",
     

Thanks.

Getting articles by i.d

Hi guys, please is there a way to get article by id, i am not seeing it in the documentation

article search api does not seem to work, when I try querying

The query is as below:-from nytimesarticle import articleAPI
api = articleAPI('4f716a9a9d8f455e908ec32b459a12ac')
articles = api.search(q="Obama",
fq={"headline": "Obama",
"source": ["Reuters",
"AP",
"The New York Times"]},
begin_date="20161001", # this can also be an int
facet_field=["source", "day_of_week"],
facet_filter=True)
////////////////////////////////////////////////////////////////////////////////////////
I get the following error:-


TypeError Traceback (most recent call last)
in ()
8 begin_date="20161001", # this can also be an int
9 facet_field=["source", "day_of_week"],
---> 10 facet_filter=True)

Z:\Anaconda\lib\site-packages\nytimesarticle.py in search(self, response_format, key, **kwargs)
109
110 url = '%s%s?%sapi-key=%s' % (
--> 111 API_ROOT, response_format, self._options(**kwargs), key
112 )
113

Z:\Anaconda\lib\site-packages\nytimesarticle.py in _options(self, **kwargs)
82 for k, v in kwargs.items():
83 if k is 'fq' and isinstance(v, dict):
---> 84 v = _format_fq(v)
85 elif isinstance(v, list):
86 v = ','.join(v)

Z:\Anaconda\lib\site-packages\nytimesarticle.py in _format_fq(d)
67 d[k] = ' '.join(map(lambda x: '"' + x + '"', v))
68 else:
---> 69 d[k] = '"' + v + '"'
70 values = []
71 for k,v in d.items():

TypeError: must be str, not bytes

can you please help me figure out if I am going wrong or if the API is broken ?

"Replies" field incomplete

Hi,

I'm trying to get all the comments on a given news article. For any returned comment c, the field "c['replies']" only contains up to 3 actual replies, whereas c['replyCount'] could indicate that there are more. When I double check on the actual web page, there are indeed a c['replyCount'] number of replies.

Is this a feature or a bug?

Thanks!
Andrew

Facets not working in articlesearch

Calls to the API including facet_field and facet_filter doenot return facets in the JSON response:

https://api.nytimes.com/svc/search/v2/articlesearch.json?q=Apple&begin_date=20170801&end_date=20170830&facet_field=source&facet_filter=true&api-key=<SOME_KEY>

The same is true for the online console:

http://developer.nytimes.com/article_search_v2.json#/Console

Incomplete Return: Only NYT picks are returned comments

I am trying to use the Community API to gather all comments on somewhat recent (2013) articles. Using the community API utility, I enter my API and the URL to the article as requested. The return does not include all comments, only those that are labelled NYT Picks on the customer facing site.
There is acknowledgement in the last lines of code that the return is less than comments found. See below:

],
"page": 1,
"totalCommentsReturned": 15,
"totalCommentsFound": 463,
"totalParentCommentsFound": 203,
"totalParentCommentsReturned": 14,
"totalReplyCommentsFound": 260,
"totalReplyCommentsReturned": 1,
"totalReporterReplyCommentsFound": 0,
"totalReporterReplyCommentsReturned": 0,
"totalEditorsSelectionFound": 15,
"totalEditorsSelectionReturned": 15,
"totalRecommendationsFound": 317,
"totalRecommendationsReturned": 15,
"replyLimit": 3,
"depthLimit": 0,
"sort": "highlights",
"filter": "highlights",
"callerID": 70037359,
"api_timestamp": "1468612511"
}
}

Two questions: is there a way to cajole the API Console to return all comments? If I were to copy the code to run this outside of the NYT hosted API, which language has been least problematic for interfacing with the community API?

Top Stories API not updating

I use the topstories endpoint of your API and noticed that it is not updating since 8/29/2018.
It used to work before that.
I checked at the web console and have the same issue.

Semantic API documentation incomplete

The docs the Semantic API say there are 4 concept types (geo, per, org, des). However it appears there are others, I've encountered porg and ttl as well. Are there any more? What do they mean?

Most Popular API: share_count returns index number

The share_count in the result object returns the index number instead of how many times an article got shared.

base_url = 'https://api.nytimes.com/svc/mostpopular/v2'
path = 'shared'
period = 7
share_type = 'email'

params = {}
params['api-key'] = 'YOUR_KEY'

url = f'{base_url}/{path}/{period}/{share_type}'

r = requests.get(url, params=params)
results = r.json()['results']
for index, result in enumerate(results, start=1):
    print(result['share_count'] == index)
    print(result['share_count'], result['title'])
True
1 Things People Say to Their Dogs
True
2 The Vegetarians Who Turned Into Butchers
True
3 A Hidden Gem of Rhode Island
True
4 The 50 Best TV Shows on Netflix Right Now
True
5 How Trump and Xi Can Make America and China Poor Again
True
6 Russian Land of Permafrost and Mammoths Is Thawing
True
7 The Who-Can-Beat Trump Test Leads to Kamala Harris
True
8 Where Hollywood’s Golden Age Stars Found Safe Harbor
True
9 White Sand, Clear Water
True
10 36 Hours on Outer Cape Cod
True
11 Was Trump’s El Paso Visit a Turning Point?
True
12 Trump’s Biggest and Most Dangerous Lie
True
13 Cancer Treatment at the End of Life
True
14 The Math Equation That Tried to Stump the Internet
True
15 What Explains U.S. Mass Shootings? International Comparisons Suggest an Answer
True
16 On Kauai, Paradise Requires Four Wheel Drive
True
17 Your Baby Boomer Report Card
True
18 Trump, Tax Cuts and Terrorism
True
19 James Comey: The President Has Exploited the Power of Racism
True
20 Craving Freedom, Japan’s Women Opt Out of Marriage

limit article search results?

hi, is there a way to limit the number of articles returned from a query?
I'd like to return only 10 articles from a given date (for example), or say 20 articles mentioning "Obama" within a data range.

Sorry if this is documented and I'm just not seeing it.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.