Skip to main content

SearchService

A list of all methods in the SearchService service. Click on the method name to view detailed information about that method.

MethodsDescription
get_articlesearch_jsonSearch for NYT articles by keywords, filters and facets.

get_articlesearch_json

Search for NYT articles by keywords, filters and facets.

  • HTTP Method: GET
  • Endpoint: /articlesearch.json

Parameters

NameTypeRequiredDescription
beginDatestringBegin date (e.g. 20120101)
endDatestringEnd date (e.g. 20121231)
facetFacetWhether to show facet counts
facetFieldsFacetFieldsFacets
facetFilterFacetFilterHave facet counts use filters
flstringField list
fqstringFilter query
pagenumberPage number (0, 1, ...)
qstringQuery
sortSortSort order

Return Type

GetArticlesearchJsonOkResponse

Example Usage Code Snippet

import { NytArticleSearch } from 'nyt-article-search';
import type { Facet, FacetFields, FacetFilter, Sort } from 'nyt-article-search';
(async () => {
try {
const nytArticleSearch = new NytArticleSearch({
apiKey: 'YOUR_API_KEY',
});

const facet: Facet = 'false';
const facetFields: FacetFields = 'day_of_week';
const facetFilter: FacetFilter = 'false';
const sort: Sort = 'newest';

const { data } = await nytArticleSearch.search.getArticlesearchJson({
facet,
facetFields,
facetFilter,
sort,
});

console.log(data);
} catch (error) {
console.error(JSON.stringify((error as any).errors, null, 2));
}
})();

Build Your Own SDKs with  liblab

Build developer friendly SDKs in minutes from your APIs

Start for Free →