ballerinax/nytimes.articlesearch Ballerina library



This is a generated connector for New York Times Article Search API v1.0.0 OpenAPI specification. With the Article Search API, you can search New York Times articles from Sept. 18, 1851 to today, retrieving headlines, abstracts, lead paragraphs, links to associated multimedia and other article metadata. Use the Article Search API to look up articles by keyword. You can refine your search using filters and facets.


Before using this connector in your Ballerina application, complete the following:


To use the New York Times Article Search connector in your Ballerina application, update the .bal file as follows:

Step 1: Import connector

First, import the ballerinax/nytimes.articlesearch module into the Ballerina project.

import ballerinax/nytimes.articlesearch as na;

Step 2: Create a new connector instance

Create a articlesearch:ApiKeysConfig with the API key obtained, and initialize the connector with it.

na:ApiKeysConfig config = {
    apiKey: "<API_KEY>"
na:Client baseClient = check new Client();

Step 3: Invoke connector operation

  1. Now you can use the operations available within the connector. Note that they are in the form of remote operations.

    Following is an example on how to look up articles by keyword using the connector. You can now search for NYT articles by keywords, filters and facets. Here we have searched for articles with the word "election".

    Look up articles by keyword

    public function main() {
        na:InlineResponse200|error response = baseClient->articleSearch("election");
        if (response is na:InlineResponse200) {
            na:InlineResponse200Response? inlineResponse200Response = response?.response;
            na:Doc[]? docs = inlineResponse200Response?.docs;
            if !(docs is ()) {
                foreach var doc in docs {
                    log:printInfo(doc?.'abstract.toString() + "\n");
        } else {
  2. Use bal run command to compile and run the Ballerina program.


import ballerinax/nytimes.articlesearch;Copy


Released date: about 1 year ago

Version: 1.5.1

License: Apache-2.0


Platform: any

Ballerina version: 2201.4.1

GraalVM compatible: Yes

Pull count

Total: 0

Current verison: 0

Weekly downloads

Source repository


Lifestyle & Entertainment/News & Lifestyle



Other versions

See more...