# JSON to JSONP API

> JSON to JSONP wraps JSON data in a JavaScript callback function to produce valid JSONP output. Pass an object or JSON string with an optional callback identifier to receive the formatted script string.

**Endpoint:** `POST https://api.apiverve.com/v1/jsontojsonp`  
**Category:** Data Conversion  
**Cost:** 1 credit per call  
**Canonical page:** https://apiverve.com/marketplace/jsontojsonp

## Overview

A JSON to JSONP API that wraps JSON data in a callback so it can be loaded with a script tag. POST a JSON object, or a JSON string, with the callback name you want, and get back the finished JSONP text together with the callback name that was used. If you leave the callback out, the name callback is used.

JSONP is still what some older widgets, embedded scripts and legacy browsers expect when a page loads data from another domain without CORS. Rather than hand-assemble the wrapper in each service, you can generate a JSONP response here and serve or cache the result, or use it to produce fixtures for testing code that consumes cross domain JSONP.

The callback name is checked before anything is built, so only a valid JavaScript function name, optionally dotted like MyApp.handlers.load, can come back in the output. The Free plan and paid plans behave the same and return the same two fields.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl -X POST "https://api.apiverve.com/v1/jsontojsonp" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"json":{"menu":{"id":"file","value":"File","popup":false}},"callback":"callbackFunction"}'
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `json` | object | Yes | The JSON data you want converted into JSONP format. Send it as an object or as a JSON-encoded string. |
| `callback` | string | No | The callback function name to wrap the JSON data. Must be a JavaScript identifier, optionally dotted (e.g. myCallback or window.myCallback).. default callback |

## Response fields

- `callback` — string · Echoes back the callback function name provided
- `jsonp` — string · JSON data wrapped in JSONP format with callback function

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "callback": "callbackFunction",
    "jsonp": "callbackFunction({\"menu\":{\"id\":\"file\",\"value\":\"File\",\"popup\":false}});"
  }
}
```

## Use cases

- **Cross-Domain Widget Feeds** — When third-party embed widgets need cross-domain data without CORS configuration, developers serve JSON payloads wrapped in dynamic client callback functions.
- **Legacy Portal Maintenance** — Engineers supporting legacy enterprise portals convert modern JSON API outputs into JSONP responses so older web clients can parse responses through script tags.
- **Static Documentation Embeds** — Technical writers embed live remote status objects into static HTML documentation sites by wrapping JSON records in custom callback handlers.
- **Client Mashup Prototyping** — To test multi-domain data feeds before updating server headers, frontend developers convert mock JSON datasets into callback-wrapped strings on demand.

## SDKs

- **npm** — `npm install @apiverve/jsontojsonp` (https://www.npmjs.com/package/@apiverve/jsontojsonp)
- **NuGet** — `dotnet add package APIVerve.API.JSONtoJSONP` (https://www.nuget.org/packages/APIVerve.API.JSONtoJSONP)
- **Source** — https://github.com/apiverve/jsontojsonp-api

## More

- Full reference: https://docs.apiverve.com/ref/jsontojsonp
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
