Få senaste sportnyheterna från den senaste veckan med cursor pagination

Så här får du de senaste sportnyheterna från den senaste veckan med cursor pagination med vårt API

Indataparameter

Parameter Description Type Default Required
category.name The category of the news articles string Yes
published_at.start The start date of the date range string Yes
published_at.end The end date of the date range string Yes
per_page The number of articles to return integer 20 Yes
next_page_cursor The starting point of the articles for cursor pagination string No

Recept för cURL

curl --location --globoff --request POST 'https://api.apitube.io/v1/news/everything?category.name=sports&published_at.start=NOW-7D&published_at.end=NOW&per_page=50&next_page_cursor=' \
--header 'Content-Type: application/json'

Recept för Python

import requests

url = "https://api.apitube.io/v1/news/everything"

querystring = {
    "category.name": "sports",
    "published_at.start": "NOW-7D",
    "published_at.end": "NOW",
    "per_page": 50,
    "next_page_cursor": ""
}
response = requests.request("GET", url, params=querystring)

print(response.text)

Recept för Javascript

import axios from "axios"

const options = {
		method: 'GET',
		url: 'https://api.apitube.io/v1/news/everything',
		params: {
    "category.name": "sports",
    "published_at.start": "NOW-7D",
    "published_at.end": "NOW",
    "per_page": 50,
    "next_page_cursor": ""
}};

axios.request(options).then(function (response) {
		console.log(response.data);
}).catch(function (error) {
		console.error(error);
});

Recept för PHP

require 'vendor/autoload.php';

use GuzzleHttp\Client;

$client = new Client();
$response = $client->request('GET', 'https://api.apitube.io/v1/news/everything', [
	'query' => [
    'category.name' => 'sports',
    'published_at.start' => 'NOW-7D',
    'published_at.end' => 'NOW',
    'per_page' => 50,
    'next_page_cursor' => '',
],
]);

echo $response->getBody();

Recept för Java

OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
		.url("https://api.apitube.io/v1/news/everything?category.name=sports&published_at.start=NOW-7D&published_at.end=NOW&per_page=50&next_page_cursor=")
		.method("POST", body)
		.addHeader("Content-Type", "application/json")
		.build();
Response response = client.newCall(request).execute();
		
  • CNN
  • Techcrunch
  • Vox
  • Apple
  • Microsoft
  • IBM
  • Bloomberg
  • Spotify