How Do I Get a Ap Feed

Feed

ON THIS PAGE Show Hide

About Long Polling

Request

Base URI Parameter

Optional Parameters

Request Headers (Optional)

Request URI Examples

Response

Response Headers

Top-Level Properties

Response Descriptive Properties

Item Descriptive Properties

Sample Feed Response

Returns a feed of content matching the specified criteria. The returned feed items are sorted in chronological order, with the newest items at the bottom of the feed.

Feeds are used for content ingestion - monitoring a stream of content to receive all updates and new content going forward. To learn more, see Typical Feed Workflow and Feed Examples in Getting Started.

About Long Polling

For efficiency on feed requests, the AP Media API server uses HTTP long polling where the server holds the client's feed request open until new content becomes available or up to 15 seconds. If there is new content when your client application makes the feed request, this content is immediately returned. Otherwise, the content is returned as soon as it becomes available during the next 15 seconds. An empty response is returned only if no new content is available after 15 seconds, which helps minimize the number of empty responses and improves efficiency.

Tip

To receive your AP breaking news content in a timely manner and to ensure your feeds do not get behind, follow the next_page link as soon as it is returned in the feed. There is no need to wait any period of time between your polling requests.

Request

  • Method: GET
  • Initial Feed Request URI (must be URL-encoded ):

    https://api.ap.org/media/v[{version}]/content/feed?apikey={apikey}[{optional_parameters}]

Important

To check for any updates since your previous feed request, you must either follow the "next_page" link from the feed response or use conditional GET requests, depending on your Feed workflow. For more information, see Best Practices for Using Feeds.

Base URI Parameter

  • version (optional). The API version; for example, 2.0. When this parameter value is not specified, the API version set as default for your account is returned.

Optional Parameters

Note

An implied AND operator is used between the parameters.

  • q. The query expression used to filter content.
  • include, exclude. Parameters used to customize the fields returned in the response. For more information, see Customizing Response Fields.
  • page_size. The maximum number of items to return per page. The default is 10 items with a maximum of 100 per page.
  • pricing. Specifying pricing=true in the request returns complete pricing information for each content item, including formatted price, use code and pricing message in addition to the price tags on renditions, which are returned by default. To learn more, see Pricing.
  • in_my_plan. Specifying in_my_plan=true in the request returns only those items that do not incur any additional cost to download. Additionally, items returned include only those associations that do not incur any additional cost to download.
  • Accept-Encoding. Compresses the response to the gzip format. The valid value is gzip.
  • x-apikey. Specifies the API key to authorize the request. The apikey parameter value takes precedence over the x-apikey header value when both are specified.

Request URI Examples

See Feed Examples in Getting Started and Supported Query Syntax.

Response

The Feed method returns the standard HTTP status code of "200 - OK" and a feed of content in the JSON format.

Each feed entry includes the content item ID, a requested set of metadata and links to all renditions of the content item (for example, thumbnail, preview and high-resolution versions of a picture).

For information about error codes, see API Codes.

  • x-mediaapi-Q-name. The API method to which the throttle/quota applies (corresponds to the "method" property returned by Account Quotas. Possible values are search, feed, account, download, ondemand, item ,other.

  • x-mediaapi-Q-secondsLeft. The number of seconds remaining in the current period.

  • x-mediaapi-Q-used. Indicates the current usage and limit (the maximum number or calls allowed during the period), in the format {usage}/{limit}; for example, 1/6.

  • x-mediaapi-QDay-minutesLeft. (Optional; returned if a per-day quota is configured) The number of minutes remaining in the current period.

  • x-mediaapi-QDay-used. (Optional; returned if a per-day quota is configured) Indicates the current usage and limit (the maximum number or calls allowed during the period), in the format {usage}/{limit}; for example, 2/5000000.

Top-Level Properties

  • api_version. The API version.
  • api_mode. The API mode; for example, "live" or "preview."
  • api_build. The API build number.
  • id. The response ID.
  • method. The API method name and HTTP method.
  • org_name. Organization name.
  • params. Parameters used in the API request.
  • data. Contains the data and metadata associated with the response.

Response Descriptive Properties

  • query. The q parameter value used in the API request.
  • updated. The date and time (in UTC) when the response was generated.
  • current_item_count. The number of items on the current page.
  • next_page. A link to the next page of the feed.

Tip

To check for any updates since your previous request, it is strongly recommended that your client application use the "next_page" link returned in the feed response for the next request. For more information, see Using Next Page Links for Content Updates.

  • items. Contains all of the items on this page.

Item Descriptive Properties

  • meta. Contains the non-content specific metadata for an item.
    • products. Contains AP products or packages to which the content item belongs.
      • id. The product or package ID.
      • name. The product or package name.
    • followedtopics. Contains AP Newsroom Followed Topics to which the content item belongs.
      • id. The Followed Topic ID.
      • name. The Followed Topic name.

Note

The "products" and "followedtopics" properties are not returned by default. Use the include parameter to include these properties in the response.

    • pricing. Pricing information for the content item (returned only when pricing=true is specified in the request). For more information, see Item Price, Use Code and Pricing and Machine-Readable Instructions.
  • item. Content-specific data and metadata for a content item. For more information, see Content Metadata Fields.

Sample Feed Response

This example shows a response to the following request:

https://api.ap.org/media/v/content/feed?q=productid:31989&include=*&apikey={apikey}

The include=* parameter is specified in this request to illustrate the "products" and "followedtopics" properties, which are not returned by default.

            {"api_version":              "2.0","api_mode":              "live","api_build":              "2.0.2","id":              "r10Q829oZ","method":              "/content/feed.GET","org_name":              "My Organization",            "params": {"include": ["*"              ],"q":              "prodictid:31989",   },"data": {"query":              "prodictid:31989","updated":              "2020-07-02T17:49:26.752Z","page_size":              10,"current_item_count":              10,"next_page":              "https://api.ap.org/media/v/content/feed?q=prodictid:31989&seq=217647413","items": [       {"meta": {"products": [             {"id":              31989,"name":              "AP Online Top General Headlines"              }           ],"followedtopics": [//              AP              Newsroom              Followed              Topics              to              which              the              content              item              belongs              ]         },"item": {//              Human-readable              usage              terms,              content              metadata              and              download              links              }       }     ]   } }          

looneycops1942.blogspot.com

Source: http://api.ap.org/media/v/docs/Feed.htm

0 Response to "How Do I Get a Ap Feed"

Postar um comentário

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel