Code Examples
Ready-to-run Contents API requests in cURL, Python, Node.js, Go, and PHP for freshness, geotargeting, and output size.
Replace YOUR_API_KEY with a key from app.lcr.net.
Send a request
The endpoint is POST https://api.lcr.net/contents, with Content-Type: application/json and a bearer token. Every example below is shown in all five languages.
curl --location 'https://api.lcr.net/contents' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
"urls": [
"https://grass.io"
],
"text": true
}'Content freshness
Controls whether content is served from cache, fetched live, or both.
Default behavior — cache-first
Serves from cache if the URL has been crawled before. Livecrawls only if no cache entry exists.
curl --location 'https://api.lcr.net/contents' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
"urls": [
"https://grass.io"
],
"text": true
}'Force a fresh livecrawl
Always fetches live, ignoring any cached content.
curl --location 'https://api.lcr.net/contents' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
"urls": [
"https://grass.io"
],
"text": true,
"maxAgeHours": 0
}'Use cache only — fastest response
Returns immediately from cache. Returns CRAWL_NOT_FOUND if the URL has never been crawled before.
curl --location 'https://api.lcr.net/contents' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
"urls": [
"https://grass.io"
],
"text": true,
"maxAgeHours": -1
}'Accept content up to 24 hours old
Serves from cache if the cached entry is less than 24 hours old, otherwise livecrawls.
curl --location 'https://api.lcr.net/contents' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
"urls": [
"https://grass.io"
],
"text": true,
"maxAgeHours": 24
}'Output size & truncation
Every result field — html, markdown, and text — is truncated to 20,000 characters by default. A large page's HTML is cut off even though the page itself is intact, so raise the limit when you need the whole thing.
Raise the character limit
maxCharacters lives inside text:
curl --location 'https://api.lcr.net/contents' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
"urls": [
"https://example.com"
],
"text": {
"maxCharacters": 200000
}
}'Get the full HTML
verbosity: "full" returns the entire <body>. The default, "compact", returns only the main content (<article> → <main> → <body> fallback). Combine it with a higher limit to get the whole page:
curl --location 'https://api.lcr.net/contents' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
"urls": [
"https://example.com"
],
"text": {
"verbosity": "full",
"maxCharacters": 200000
}
}'verbosity affects text only — html and markdown always cover the full page, up to maxCharacters.
maxCharactersmust be a positive number. Missing,0, negative, or non-numeric values fall back to 20,000.- Larger values increase response size and latency. They do not cost extra credits.
- To omit
textentirely while keepinghtmlandmarkdown, passtext: false.
Cached responses are capped at 20,000 characters
Content is stored in the cache truncated to 20,000 characters. A response served
from cache ("source": "cached" or "cached-fallback") returns at most 20,000
characters regardless of the maxCharacters you request. To reliably get
full-length HTML, force a livecrawl with "maxAgeHours": 0.
Geotargeting
Use countryCode to route the crawl through a proxy in a specific country. This matters because many sites serve different content per country — prices, currency, language, and even availability change based on where the request comes from.
Match the country code to the site
Set countryCode to the same country as the storefront you want. For a site that already targets a country, using that country's code returns its localized content instead of the default US version.
For example, ph.shein.com is Shein's Philippine storefront. Crawl it with "countryCode": "ph":
curl --location 'https://api.lcr.net/contents' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
"urls": [
"https://ph.shein.com/"
],
"text": true,
"countryCode": "ph"
}'With the default countryCode (us), the same URL can return the US storefront instead — different products, prices in USD, and US-English copy.
Country codes
Pass a two-letter ISO 3166-1 alpha-2 code. Values are lowercased and trimmed, and
uk is accepted as an alias for gb. If you omit countryCode, requests route
through the us default.
Query parameters in the URL (lang, currency, skucode, …) are sent as-is and can change the response further — geo routing selects the regional storefront, and those parameters refine what it returns.
Fetch content from the US
curl --location 'https://api.lcr.net/contents' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
"urls": [
"https://example.com"
],
"text": true,
"countryCode": "us"
}'Fetch content from the UK
curl --location 'https://api.lcr.net/contents' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
"urls": [
"https://example.com"
],
"text": true,
"countryCode": "gb"
}'Combine geotargeting with freshness
You can combine countryCode with maxAgeHours to control both the geographic location and the freshness of the content.
curl --location 'https://api.lcr.net/contents' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
"urls": [
"https://example.com"
],
"text": true,
"countryCode": "us",
"maxAgeHours": 24
}'Combine with freshness and timeouts
text options, maxAgeHours, and livecrawlTimeout compose. This request forces a fresh crawl, waits up to 15 seconds for it, and returns the whole body text plus HTML up to 200,000 characters:
curl --location 'https://api.lcr.net/contents' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--data '{
"urls": [
"https://grass.io"
],
"maxAgeHours": 0,
"text": {
"verbosity": "full",
"maxCharacters": 200000
},
"livecrawlTimeout": 15000
}'
