emergentmethods/asknews-php-sdk

AskNews API

Installs: 8 268

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/emergentmethods/asknews-php-sdk

0.3.7 2025-10-31 14:15 UTC

README

AskNews API

Installation & Usage

Requirements

PHP 8.0 and later.

Composer

To install the bindings via Composer, add the following to composer.json:

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/emergentmethods/asknews-php-sdk.git"
    }
  ],
  "require": {
    "emergentmethods/asknews-php-sdk": "*@dev"
  }
}

Then run composer install

Manual Installation

Download the files and include autoload.php:

<?php
require_once('/path/to/asknews-php-sdk/vendor/autoload.php');

Getting Started

Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');





// Configure sdk credentials
$config = new AskNews\Configuration([
  'clientId' => 'YOUR_ASKNEWS_CLIENT_ID',
  'clientSecret' => 'YOUR_ASKNEWS_CLIENT_SECRET',
  'scopes' => ['news', 'chat', 'stories', 'analytics']
]);


$apiInstance = new AskNews\Api\AlertsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$create_alert_request = new \AskNews\Model\CreateAlertRequest(); // \AskNews\Model\CreateAlertRequest

try {
    $result = $apiInstance->createAlert($create_alert_request);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling AlertsApi->createAlert: ', $e->getMessage(), PHP_EOL;
}

API Endpoints

All URIs are relative to https://api.asknews.app

Class Method HTTP request Description
AlertsApi createAlert POST /v1/chat/alerts Create an alert
AlertsApi deleteAlert DELETE /v1/chat/alerts/{alert_id} Delete an alert
AlertsApi getAlert GET /v1/chat/alerts/{alert_id} Get an alert
AlertsApi getAlertLogs GET /v1/chat/alerts/{alert_id}/logs Get alert logs
AlertsApi getAlerts GET /v1/chat/alerts Get all created alerts
AlertsApi getAllAlertLogs GET /v1/chat/alerts/logs Get all alert logs
AlertsApi putAlert PUT /v1/chat/alerts/{alert_id} Update an alert
AlertsApi runAlert GET /v1/chat/alerts/{alert_id}/run Run an existing alert
AnalyticsApi getAssetSentiment GET /v1/analytics/finance/sentiment Get a timeseries of finance news sentiment for assets
AutofilterApi autofilter GET /v1/chat/autofilter Generate filter params for AskNews endpoints
ChatApi deepNews POST /v1/chat/deepnews Deep research into real-time news, archive news, and Google.
ChatApi getChatCompletions POST /v1/openai/chat/completions Get chat completions from a news-infused AI assistant
ChatApi getHeadlineQuestions GET /v1/chat/questions Get example headline questions
ChatApi listChatModels GET /v1/openai/models List available chat models
DistributionApi domainHitShare GET /v1/distribution/stats/hit_share Get the hit share for a list of domains in a time period
DistributionApi findDomains GET /v1/distribution/domains Find domains
DistributionApi getArticleHits GET /v1/distribution/stats/count Get article hits
DistributionApi getDomain GET /v1/distribution/domains/{name} Get a domain by name
DistributionApi getDomainQueries GET /v1/distribution/articles/domain_queries Get queries that surfaced domain articles
DistributionApi topNArticlesByHits GET /v1/distribution/articles/top_n Get the top N articles by hits
DistributionApi topNArticlesForDomain GET /v1/distribution/articles/top_n_for_domain Get the top N articles by hits for domain
DistributionApi topNDomainsByHits GET /v1/distribution/domains/top_n Get the top N domains by hits
DistributionApi updateDomain PUT /v1/distribution/domains/{name} Update an existing domain
ForecastApi getForecast GET /v1/chat/forecast Make an expert forecast for a news event.
GraphApi buildGraph POST /v1/news/graph Build a custom mega-news-knowledge graph
NewsApi getArticle GET /v1/news/{article_id} Get an article by its UUID
NewsApi getArticles GET /v1/news Get multiple articles by UUID
NewsApi getIndexCounts GET /v1/index_counts Get the index counts underlying AskNews
NewsApi getSourcesReport GET /v1/sources Get the sources underlying AskNews
NewsApi searchNews GET /v1/news/search Search for enriched real-time news context
NewslettersApi deleteNewsletter DELETE /v1/chat/newsletters/{newsletter_id} Delete a newsletter
NewslettersApi deleteNewsletterContact DELETE /v1/chat/newsletters/{newsletter_id}/contacts/{contact_id} Delete a newsletter contact
NewslettersApi getNewsletter GET /v1/chat/newsletters/{newsletter_id} Get a newsletter
NewslettersApi getNewsletterContact GET /v1/chat/newsletters/{newsletter_id}/contacts/{contact_id} Get a newsletter contact
NewslettersApi getNewsletterContacts GET /v1/chat/newsletters/{newsletter_id}/contacts Get newsletter contacts
NewslettersApi getNewsletters GET /v1/chat/newsletters Get all created newsletters
NewslettersApi getPublicNewsletters GET /v1/chat/newsletters/public Get all public newsletters
NewslettersApi patchNewsletterContact PATCH /v1/chat/newsletters/{newsletter_id}/contacts/{contact_id} Update a newsletter contact
NewslettersApi postNewsletter POST /v1/chat/newsletters Create a newsletter
NewslettersApi postNewsletterContacts POST /v1/chat/newsletters/{newsletter_id}/contacts Create a newsletter contact
NewslettersApi putNewsletter PUT /v1/chat/newsletters/{newsletter_id} Update a newsletter
NewslettersApi unsubscribeNewsletter POST /v1/chat/newsletters/{newsletter_id}/unsubscribe Unsubscribe from a newsletter
PingApi ping GET / Ping
ProfileApi getUserProfile GET /v1/profiles/me Get the current user's profile
RedditApi searchReddit GET /v1/reddit/search Search Reddit, summarize threads, and return analysis.
StoriesApi getStories GET /v1/stories Filter and search for top news narratives
StoriesApi getStory GET /v1/stories/{story_id} Get a story containing updates
WebsearchApi liveWebSearch GET /v1/chat/websearch Run a live websearch.
WikiApi searchWiki GET /v1/wiki/search Search for Wikipedia context with natural language

Models

Authorization

Find full details at the AskNews API documentation.

Support

Join our Discord to see what other people are building, and to get support with your projects.