Skip to content

Usage Examples

All examples use Python 3 with the requests library. Replace <your-neuron-api-key> with the key from your Neuron API access profile tab.

python
import json, requests

API_ENDPOINT = 'https://app.neuronwriter.com/neuron-api/0.5/writer'
API_KEY = '<your-neuron-api-key>'

headers = {
    "X-API-KEY": API_KEY,
    "Accept": "application/json",
    "Content-Type": "application/json",
}

1. Create a new query

python
payload = json.dumps({
    # Project ID from the project URL:
    # https://app.neuronwriter.com/project/view/c2fe46bce8019bff/optimisation -> c2fe46bce8019bff
    "project": "c2fe46bce8019bff",
    "keyword": "trail running shoes",
    "engine": "google.co.uk",
    "language": "English",
    "additional_keywords": ["off-road running shoes", "mountain running shoes"],
})

response = requests.post(API_ENDPOINT + "/new-query", headers=headers, data=payload)
print(response.text)

2. Create a query with top-intent competitors

python
payload = json.dumps({
    "project": "c2fe46bce8019bff",
    "keyword": "trail running shoes",
    "engine": "google.co.uk",
    "language": "English",
    "additional_keywords": ["off-road running shoes", "mountain running shoes"],
    "competitors_mode": "top-intent",  # recommendations based on URLs matching the most popular intent
})

response = requests.post(API_ENDPOINT + "/new-query", headers=headers, data=payload)
print(response.text)

3. Get recommendations for a query

python
payload = json.dumps({"query": "79ca6b6b45fb9d67"})
response = requests.post(API_ENDPOINT + "/get-query", headers=headers, data=payload)
data = response.json()

if data["status"] == "ready":
    print("Target word count:", data["metrics"]["word_count"]["target"])
    print("Title term suggestions:", data["terms_txt"]["title"])

4. Get the saved content for a query

python
payload = json.dumps({"query": "79ca6b6b45fb9d67"})
response = requests.post(API_ENDPOINT + "/get-content", headers=headers, data=payload)
r = response.json()

print('########### title: ###########')
print(r['title'])
print('########### description: ###########')
print(r['description'])
print('########### HTML content: ###########')
print(r['content'])

5. Import a draft into the editor

python
payload = json.dumps({
    "query": "f67d0dac14a35a86",
    "html": """<h1>Best Trail Running Shoes in 2024: A Complete Guide</h1>
<p>As a trail runner, choosing the right pair of trail running shoes is crucial...</p>
<h2>What makes a great trail running shoe?</h2>
<p>When looking for the perfect trail running shoe, there are several key features to consider...</p>""",
    "title": "Best Trail Running Shoes in 2024: A Complete Guide",
    "description": "Discover the top trail running shoes of 2024, including models from Altra, Hoka, Nike, and more.",
})

response = requests.post(API_ENDPOINT + "/import-content", headers=headers, data=payload)
print(response.json())
# {"status": "ok", "content_score": 25}

Feedback

This is a beta API. Bugs and feature requests go to NeuronWriter's API feedback form (linked from the official API help article).