Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Connect AI agents to NewsAPI

Scalekit connector
Open markdown

The NewsAPI connector lets your AI agent act in each user's NewsAPI account. Each user connects their own NewsAPI API key once, and Scalekit sends it with every call, so your agent never handles credentials. It comes with 3 tools.

Tools
3
What they doRead · write · destructive
3 · 0 · 03 read0 write0 destructive
Users sign in with

Setup

  1. Install the SDK

    Terminal window
    npm install @scalekit-sdk/node dotenv
  2. Set your credentials

    Add your Scalekit credentials to your .env file. Find values in app.scalekit.com > Developers > API Credentials.

    .env
    SCALEKIT_ENVIRONMENT_URL=<your-environment-url>
    SCALEKIT_CLIENT_ID=<your-client-id>
    SCALEKIT_CLIENT_SECRET=<your-client-secret>
  3. Create the NewsAPI connection

    In AgentKit > Connections, create a NewsAPI connection. The name you give it is the connection_name your code passes. See Configure connections.

  4. Authorize a user and make your first call

    quickstart.mts
    import { ScalekitClient } from '@scalekit-sdk/node'
    import 'dotenv/config'
    import { createInterface } from 'node:readline/promises'
    const scalekit = new ScalekitClient(
    process.env.SCALEKIT_ENVIRONMENT_URL,
    process.env.SCALEKIT_CLIENT_ID,
    process.env.SCALEKIT_CLIENT_SECRET,
    )
    const actions = scalekit.actions
    const connector = 'newsapi'
    const identifier = 'user_123'
    // Generate an authorization link for the user
    const { link } = await actions.getAuthorizationLink({ connectionName: connector, identifier })
    console.log('Authorize NewsAPI:', link)
    const rl = createInterface({ input: process.stdin, output: process.stdout })
    await rl.question('Press Enter after authorizing...')
    rl.close()
    // Make your first call
    const result = await actions.executeTool({
    connector,
    identifier,
    toolName: 'newsapi_articles_search',
    toolInput: {},
    })
    console.log(result)
    Terminal window
    npx tsx quickstart.mts

    Each user opens the link once and enters their NewsAPI credentials there. See Authorize a user for the full flow and statuses.

Tools

Pass the exact name to execute_tool
Try in PlaygroundRequest a tool
  • newsapi_sources_listList the news sources available for top headlines, optionally filtered by category, language or country.Read-only

    List News Sources

    List the news sources available for top headlines, optionally filtered by category, language or country. Returns sources with id, name, description, url, category, language and country. Use this to find source IDs for newsapi_top_headlines_list or newsapi_articles_search.

    Inputs

    categorystring
    Only sources that publish this category. Defaults to all categories. Example: business.one of businessentertainmentgeneralhealthsciencesportstechnology
    countrystring
    Only sources based in this two-letter ISO 3166-1 country. Defaults to all countries. Example: gb.one of aearataubebgbrcachcncocuczdeegfrgbgrhkhuidieilinitjpkrltlvmamxmyngnlnonzphplptrorsrusasesgsiskthtrtwuausveza
    languagestring
    Only sources in this two-letter ISO-639-1 language. Defaults to all languages. Example: en.one of ardeenesfrheitnlnoptrusvudzh
  • newsapi_top_headlines_listList live top and breaking headlines by country, category, source or keyword.Read-only

    List Top Headlines

    List live top and breaking headlines by country, category, source or keyword. Returns status, totalResults and articles with source, author, title, description, url, urlToImage, publishedAt and content. Use this for current headlines. Use newsapi_articles_search to search all articles over time. Do not combine sources with country or category.

    Inputs

    categorystring
    Headline category. Cannot be combined with sources. Example: technology.one of businessentertainmentgeneralhealthsciencesportstechnology
    countrystring
    Two-letter ISO 3166-1 country code to get headlines for. Cannot be combined with sources. Example: us.
    pageinteger
    Page number to return, starting at 1. Defaults to 1. Example: 1.
    page_sizeinteger
    Number of articles per page. Defaults to 20, maximum 100. Example: 20.
    qstring
    Keywords or a phrase to search for in the headlines. Example: election.
    sourcesstring
    Comma-separated source IDs to get headlines from. Get IDs from newsapi_sources_list. Cannot be combined with country or category. Example: bbc-news.