Skip to content

Instantly share code, notes, and snippets.

@zeshanshani
Created February 26, 2026 11:41
Show Gist options
  • Select an option

  • Save zeshanshani/613ef8e6e45275780b7a0d5954eb159a to your computer and use it in GitHub Desktop.

Select an option

Save zeshanshani/613ef8e6e45275780b7a0d5954eb159a to your computer and use it in GitHub Desktop.
# Retrieve a single article and its image with requests
import requests
BASE = "https://web-news-service.greenstreet.com"
def get_article(token, article_id):
r = requests.get(f"{BASE}/api/articles/{article_id}", headers={"Authorization": f"Bearer {token}"})
r.raise_for_status()
return r.json()
def get_featured_image(token, article_id, src, region):
r = requests.get(
f"{BASE}/api/articles/{article_id}/image",
headers={"Authorization": f"Bearer {token}"},
params={"src": src, "region": region},
)
r.raise_for_status()
return r.content # binary image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment