### Get Content API Example (JavaScript) Source: https://neuronwriter.com/faqs/neuronwriter-api-how-to-use This JavaScript snippet shows how to use the Fetch API to call the /get-content endpoint. It demonstrates retrieving content for a specific query ID, optionally including autosave revisions, and handling the response. ```javascript const apiKey = "YOUR_API_KEY"; const queryId = "32dee2a89374a722"; const revisionType = "all"; // or "manual" fetch(`https://api.neuronwriter.com/v1/get-content?query=${queryId}&revision_type=${revisionType}`, { method: "GET", headers: { "X-Api-Key": apiKey, "Content-Type": "application/json" } }) .then(response => { if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return response.json(); }) .then(data => { console.log(JSON.stringify(data, null, 2)); }) .catch(error => { console.error("Error fetching content:", error); }); ``` -------------------------------- ### NeuronWriter API Usage Example (Python) Source: https://neuronwriter.com/faqs/neuronwriter-api-how-to-use Example code snippet demonstrating how to create a new query using the NeuronWriter API with Python and the requests library. ```APIDOC #coding=utf-8 import json import requests API_ENDPOINT = 'https://app.neuronwriter.com/neuron-api/0.5/writer' API_KEY = 'n-c17ef87a9ab8285ea7ef06064031fad4' headers = { "X-API-KEY": API_KEY, "Accept": "application/json", "Content-Type": "application/json", } # Creating a new query: payload = json.dumps({ # Project ID can be found in the project’s URL: https://app.neuronwriter.com/project/view/c2fe46bce8019bff/optimisation -> c2fe46bce8019bff "project": "c2fe46bce8019bff", "keyword": "trail running shoes", "engine": "google.co.uk", "language": "English", }) response = requests.request("POST", API_ENDPOINT + "/new-query", headers=headers, data=payload) print(response.text) # Output (JSON): # {"query": "79ca6b6b45fb9d67", "query_url": "https://app.neuronwriter.com/analysis/view/79ca6b6b45fb9d67", "share_url": "https://app.neuronwriter.com/analysis/share/79ca6b6b45fb9d67/cceca0f2e01e17e998e72eaa2d4030261562", "readonly_url": "https://app.neuronwriter.com/analysis/content-preview/79ca6b6b45fb9d67/96e0109dea412bb07690999de5cb67ce1562"} ``` -------------------------------- ### List Queries API Example (Python) Source: https://neuronwriter.com/faqs/neuronwriter-api-how-to-use This Python snippet demonstrates how to call the /list-queries endpoint to retrieve a list of queries within a project. It shows how to specify parameters like project ID, status, and source, and processes the JSON response. ```python import requests import json api_key = "YOUR_API_KEY" project_id = "0c30b6a4f8b2b412" headers = { "X-Api-Key": api_key } params = { "project": project_id, "status": "ready", "source": "neuron-api" } response = requests.get("https://api.neuronwriter.com/v1/list-queries", headers=headers, params=params) if response.status_code == 200: queries = response.json() print(json.dumps(queries, indent=2)) else: print(f"Error: {response.status_code}") print(response.text) ``` -------------------------------- ### Check Query Status and Get Recommendations (Python) Source: https://neuronwriter.com/faqs/neuronwriter-api-how-to-use This Python script uses the NeuronWriter API to check if a query is ready and then prints various recommendations. It requires the `requests` and `json` libraries. The script takes a query ID as input and outputs word count, terms, questions, and competitor data if the query status is 'ready'. ```python #coding=utf-8 import json import requests API_ENDPOINT = ‘https://app.neuronwriter.com/neuron-api/0.5/writer’ API_KEY = ‘n-c17ef87a9ab8285ea7ef06064031fad4’ headers = { “X-API-KEY”: API_KEY, “Accept”: “application/json”, “Content-Type”: “application/json”, } payload = json.dumps({ “query”: “79ca6b6b45fb9d67”, # query ID returned by /new-query request }) response = requests.request(“POST”, API_ENDPOINT + “/get-query”, headers=headers, data=payload) response_data = response.json() if response_data[‘status’] == ‘ready’: # We’ve finished the analysis print(‘########### WORD COUNT: ###########’) print(response_data[‘metrics’][‘word_count’][‘target’]) print(‘########### TERMS: ###########’) print(‘########### title terms: ###########’) print(response_data[‘terms_txt’][‘title’]) print(‘########### basic content terms: ###########’) print(response_data[‘terms_txt’][‘content_basic’]) print(‘########### basic content terms with use ranges: ###########’) print(response_data[‘terms_txt’][‘content_basic_w_ranges’]) print(‘########### entities: ###########’) print(response_data[‘terms_txt’][‘entities’]) print(‘########### SUGGEST QUESTIONS: ###########’) for q in response_data[‘ideas’][‘suggest_questions’]: print(q[‘q’]) print(‘########### PAA QUESTIONS: ###########’) for q in response_data[‘ideas’][‘people_also_ask’]: print(q[‘q’]) print(‘########### CONTENT QUESTIONS: ###########’) for q in response_data[‘ideas’][‘content_questions’]: print(q[‘q’]) print(‘########### COMPETITORS: ###########’) for comp in response_data[‘competitors’]: print(comp[‘rank’], ‘|’, comp[‘url’]) print(‘ TITLE:’, comp[‘title’]) print(‘ CONTENT SCORE:’, comp[‘content_score’]) else: pass # Try again later… ``` -------------------------------- ### API Response Structure for /list-queries Source: https://neuronwriter.com/faqs/neuronwriter-api-how-to-use Example JSON structure representing the response from the /list-queries API endpoint. It includes details for each query such as its ID, creation and update timestamps, keyword, language, engine, source, and associated tags. ```json [ { "query": "a6d0fb2bf9a7a2be", "created": "2024-01-19T14:48:31+00:00", "updated": "2024-01-19T14:49:52+00:00", "keyword": "how should running shoes fit", "language": "English", "engine": "google.co.uk", "source": "neuron-api", "tags": ["Done"] }, { "query": "bdc73d8e0057ed8f", "created": "2024-01-19T14:48:31+00:00", "updated": "2024-01-19T14:49:52+00:00", "keyword": "trail running shoes for winter", "language": "English", "engine": "google.co.uk", "source": "neuron-api", "tags": ["Done"] } ] ``` -------------------------------- ### API Response Example Source: https://neuronwriter.com/faqs/neuronwriter-api-how-to-use This JSON object represents a typical successful response from the NeuronWriter API after updating content. It indicates the status and a content score. ```json {"status": "ok", "content_score": 25} ``` -------------------------------- ### GET /get-content Source: https://neuronwriter.com/faqs/neuronwriter-api-how-to-use Retrieves the last content revision saved for a given query. This endpoint can fetch manually saved revisions or include all revisions (including autosave). ```APIDOC ## GET /get-content ### Description Retrieves the last content revision saved for a given query. Any query, doesn’t have to be created via API. You can choose between manually saved revisions (default) or all (including autosave revisions). ### Method GET ### Endpoint /get-content ### Parameters #### Query Parameters - **query** (string) - Required - The ID of your query. - **revision_type** (string) - Optional - Whether autosave revisions should be considered or not. Possible values: `all` or `manual` (default). ### Response #### Success Response (200) Returns detailed content analysis, including metrics, terms, ideas, and competitor information. The exact structure depends on the query and available data. #### Response Example ```json { "status": "ready", "metrics": { "word_count": {"median": 1864, "target": 1864}, "readability": {"median": 40, "target": 40} }, "terms_txt": { "title": "running shoenwinter running shoenbest winter running shoenwinter running shoes of 2024", "desc_title": "running shoenwinter running shoenbest winter running shoentractionnbest pairsnwinter running shoes of 2024n2024ntrail runningnshoes for runningnrunning in the winternfeet warmnwinter shoes", "h1": "running shoe…" }, "terms": { "title": [ {"t": "running shoe", "usage_pc": 88}, {"t": "winter running shoe", "usage_pc": 75}, {"t": "best winter running shoe", "usage_pc": 62}, {"t": "winter running shoes of 2024", "usage_pc": 50} ], "desc": [ {"t": "running shoe", "usage_pc": 25}, {"t": "winter running shoe", "usage_pc": 25}, {"t": "best winter running shoe", "usage_pc": 25} ], "content_basic": [ {"t": "running shoe", "usage_pc": 88, "sugg_usage": [1, 32]}, {"t": "winter running shoe", "usage_pc": 88, "sugg_usage": [1, 9]}, {"t": "best winter running shoe", "usage_pc": 75, "sugg_usage": [1, 2]}, {"t": "winter running shoes of 2024", "usage_pc": 50, "sugg_usage": [1, 1]}, {"t": "2024", "usage_pc": 75, "sugg_usage": [1, 2]}, {"t": "traction", "usage_pc": 62, "sugg_usage": [1, 16]}, {"t": "outsole", "usage_pc": 62, "sugg_usage": [1, 19]} ], "entities": [ {"t": "Trail running", "importance": 27.31264, "relevance": 0.42676, "confidence": 3.2872, "links": [["wikipedia", ""]]} ] }, "ideas": { "suggest_questions": [ {"q": "where to buy trail running shoes"}, {"q": "are trail running shoes comfortable"} ], "people_also_ask": [ {"q": "What is the difference between a running shoe and a trail running shoe?"}, {"q": "Can running shoes be used for trail?"} ], "content_questions": [ {"q": "Can I use road running shoes for trail running?"}, {"q": "How many miles do trail running shoes last?"} ] }, "competitors": [ { "rank": 1, "url": "https://www.runnersworld.com/gear/a22115120/best-trail-running-shoes/", "title": "The 11 Best Trail Running Shoes of 2024 – Best Off-Road Running Shoes", "desc": "Check out the Runner’s World editors’ picks for the 11 best trail and off-road running shoes so far in 2024. " } ] } ``` ``` -------------------------------- ### POST /get-query Source: https://neuronwriter.com/faqs/neuronwriter-api-how-to-use Retrieves content recommendations for a given query ID. Analysis typically takes about 60 seconds after creation. ```APIDOC ## POST /get-query ### Description Retrieves content recommendations for a given query. This method can be used for any query, not just those created via the API. Recommendations are typically available about 60 seconds after query creation. ### Method POST ### Endpoint `https://app.neuronwriter.com/neuron-api/0.5/writer/get-query` ### Parameters #### Request Body - **query** (string) - Required - The ID of your query (e.g., `32dee2a89374a722`). ### Request Example ```json { "api_key": "YOUR_API_KEY", "query": "32dee2a89374a722" } ``` ### Response #### Success Response (200) * The response structure for a successful query retrieval is not explicitly detailed in the provided text, but it is indicated that recommendations are available when `status=='ready'`. #### Response Example (Example structure based on typical API responses for this type of data) ```json { "query_id": "32dee2a89374a722", "status": "ready", "recommendations": [ { "title": "Top 10 Trail Running Shoes for 2023", "url": "https://example.com/article1", "score": 0.95 }, { "title": "Choosing the Right Trail Running Shoes", "url": "https://example.com/article2", "score": 0.92 } ] } ``` ``` -------------------------------- ### Get Content Source: https://neuronwriter.com/faqs/neuronwriter-api-how-to-use Retrieves the last saved content revision for a given query. This endpoint is useful for fetching the generated title, description, and HTML content associated with a specific query. ```APIDOC ## POST /get-content ### Description Retrieves the last content revision saved for a given query. ### Method POST ### Endpoint https://app.neuronwriter.com/neuron-api/0.5/writer/get-content ### Parameters #### Headers - **X-API-KEY** (string) - Required - Your NeuronWriter API key. - **Accept** (string) - Optional - `application/json`. - **Content-Type** (string) - Optional - `application/json`. #### Request Body - **query** (string) - Required - The ID of the query for which to retrieve content. ### Request Example ```json { "query": "79ca6b6b45fb9d67" } ``` ### Response #### Success Response (200) - **title** (string) - The title of the content. - **description** (string) - The meta description for the content. - **content** (string) - The main HTML content. #### Response Example ```json { "title": "Top 10 Best Winter Running Shoes of 2024 - Find the Perfect Pair for Cold Weather Runs", "description": "Discover the top 10 best winter running shoes of 2024 for staying warm and steady on your cold weather runs. Find the perfect pair with great traction!", "content": "

Top 10 Best Winter Running Shoes of 2024 - Find the Perfect Pair for Cold Weather Runs

Winter running shoes are designed to provide the necessary support, comfort, and protection for running in cold and icy conditions. The top winter running shoes of 2024 not only keep your feet warm and dry but also offer traction and stability on slippery surfaces. These shoes typically feature waterproof membranes, durable outsoles with lugs for enhanced grip, and insulated uppers to shield your feet from the chilly weather.

..." } ``` ``` -------------------------------- ### Create New Query using Python Source: https://neuronwriter.com/faqs/neuronwriter-api-how-to-use Demonstrates how to create a new query using the NeuronWriter API with Python's requests library. It includes setting up the API endpoint, headers, and the JSON payload for the request. ```Python #coding=utf-8 import json import requests API_ENDPOINT = 'https://app.neuronwriter.com/neuron-api/0.5/writer' API_KEY = 'n-c17ef87a9ab8285ea7ef06064031fad4' headers = { "X-API-KEY": API_KEY, "Accept": "application/json", "Content-Type": "application/json", } # Creating a new query: payload = json.dumps({ # Project ID can be found in the project’s URL: https://app.neuronwriter.com/project/view/c2fe46bce8019bff/optimisation -> c2fe46bce8019bff "project": "c2fe46bce8019bff", "keyword": "trail running shoes", "engine": "google.co.uk", "language": "English", }) response = requests.request("POST", API_ENDPOINT + "/new-query", headers=headers, data=payload) print(response.text) ```