Thrift Calculator Service Example
A complete example of the classic Apache Thrift tutorial Calculator service, showing IDL constructs converted to JSON representation
Thrift Calculator Service Example is an example object payload from Apache Thrift, with 11 top-level fields. It illustrates the shape of data this provider's APIs accept or return.
Top-level fields
Example Payload
{
"title": "Apache Thrift Calculator Service - IDL Example",
"description": "A complete example of the classic Apache Thrift tutorial Calculator service, showing IDL constructs converted to JSON representation",
"source": "https://github.com/apache/thrift/blob/master/tutorial/tutorial.thrift",
"idl_source": "tutorial.thrift",
"namespace": {
"cpp": "tutorial",
"d": "tutorial",
"dart": "tutorial",
"java": "tutorial",
"php": "tutorial",
"perl": "tutorial",
"haxe": "tutorial",
"netstd": "tutorial"
},
"includes": [
"shared.thrift"
],
"constants": [
{
"type": "i32",
"name": "INT32CONSTANT",
"value": 9853
},
{
"type": "map",
"typeArgs": { "key": "string", "value": "string" },
"name": "MAPCONSTANT",
"value": { "hello": "world", "goodnight": "moon" }
}
],
"enums": [
{
"name": "Operation",
"comment": "Mathematical operations supported by the calculator service",
"values": [
{ "name": "ADD", "value": 1 },
{ "name": "SUBTRACT", "value": 2 },
{ "name": "MULTIPLY", "value": 3 },
{ "name": "DIVIDE", "value": 4 }
]
}
],
"structs": [
{
"name": "Work",
"comment": "A work item representing a single calculation request",
"fields": [
{ "id": 1, "type": "i32", "name": "num1", "default": 0, "comment": "First operand" },
{ "id": 2, "type": "i32", "name": "num2", "comment": "Second operand" },
{ "id": 3, "type": "Operation", "name": "op", "comment": "The operation to perform" },
{ "id": 4, "type": "string", "name": "comment", "requiredness": "optional", "comment": "Optional comment for this calculation" }
]
}
],
"exceptions": [
{
"name": "InvalidOperation",
"comment": "Exception thrown when an invalid or illegal operation is requested",
"fields": [
{ "id": 1, "type": "i32", "name": "whatOp" },
{ "id": 2, "type": "string", "name": "why" }
]
}
],
"services": [
{
"name": "Calculator",
"comment": "A calculator service extending the shared SharedService",
"extends": "shared.SharedService",
"functions": [
{
"oneway": true,
"returnType": "void",
"name": "ping",
"parameters": [],
"comment": "A method definition without a return type means void; one-way function sends and does not wait"
},
{
"returnType": "i32",
"name": "add",
"parameters": [
{ "id": 1, "type": "i32", "name": "num1" },
{ "id": 2, "type": "i32", "name": "num2" }
],
"comment": "Adds two integers and returns the result"
},
{
"returnType": "i32",
"name": "calculate",
"parameters": [
{ "id": 1, "type": "i32", "name": "logid", "comment": "Log entry ID for audit purposes" },
{ "id": 2, "type": "Work", "name": "w", "comment": "The work item describing the calculation" }
],
"throws": [
{ "id": 1, "type": "InvalidOperation", "name": "ouch" }
],
"comment": "Performs the specified calculation; throws InvalidOperation if the operation is illegal"
},
{
"returnType": "void",
"name": "zip",
"parameters": [],
"comment": "This method has a bug in the parameters; it should have been an exception in thrift IDL"
}
]
}
]
}
Work with this as data
Every example here is available over the APIs.io API and to AI agents over MCP.
MCP server
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
Tools for examples
4 MCP tools reach this
find_examplesBrowse and filter every example in the catalog.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.
Call it yourself
curl for this page
curl "https://apis.io/api/v1/examples/thrift-calculator-service-example"
curl "https://apis.io/api/v1/examples?limit=25"
Discovery needs no key. Ratings and market analysis are Pro.
Get an API key
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.