ngrams-dev / general

NGRAMS is a search engine for the Google Books Ngram Dataset. This repository contains documentation, discussions, announcements, and issues.
https://ngrams.dev
14 stars 0 forks source link

Provide example code for common programming languages #5

Open mtrenkmann opened 1 year ago

mtrenkmann commented 1 year ago

The reworked NGRAMS Documentation (the GitHub Wiki is temporary) should include request examples for at least curl, JavaScript, TypeScript, Python, and NodeJS.

A tool to map curl commands to other languages is https://curlconverter.com. Thanks @MarkAPitt for pointing to it.

MarkAPitt commented 1 year ago

Consider also providing an example of how to decode the returned object when in batch mode. This worked for my purposes.

response = requests.post(....)
data = response.content.decode('utf-8')
datalist = json.loads(data)
michaelmior commented 3 months ago

@MarkAPitt Assuming you're using the Python requests library, you can simplify that to

datalist = requests.post(....).json()