Working on structured data for a client's blog, I needed a quick way to generate JSON-LD for different schema types. Here's a script that uses the SERPSpur API to create Article and FAQ schemas:
python
import requests
API_KEY = "your_api_key_here"
def generate_schema(schema_type, content):
response = requests.post(
"https://api.serpspur.com/v1/schema/generate",
headers={"Authorization": f"Bearer {API_KEY}"},
json={"type": schema_type, "content": content}
)
return response.json()["json_ld"]
Generate FAQ schema for a blog post
faq_data = {
"mainEntity": [
{"name": "What is SEO?", "acceptedAnswer": {"text": "SEO stands for Search Engine Optimization."}},
{"name": "Why is schema important?", "acceptedAnswer": {"text": "Schema helps search engines understand your content."}}
]
}
schema_output = generate_schema("FAQPage", faq_data)
print(schema_output)
This made it easy to test different schema variations without manual JSON editing. Have you found any tricky schema types that are harder to automate?
Top comments (3)
Great script! I've found Product schema a pain to automate because of all the nested properties like offers and reviews. Have you tried generating that with this API yet?
Nice approach! I've found that
Productschemas can be tricky due to all the nested properties (like offers, reviews, and aggregate ratings). Automating those with an API definitely saves time.Some comments may only be visible to logged-in visitors. Sign in to view all comments.