Skip to main content

Stone is an interface description language (IDL) for APIs.

Project description

Warning: The documentation is undergoing a rewrite.

https://travis-ci.org/dropbox/stone.svg?branch=master

Define an API once in Stone. Use backends, i.e. code generators, to translate your specification into objects and functions in the programming languages of your choice.

Overview

docs/overview.png

Stone is made up of several components:

Language

A language for writing API specifications, “specs” for short.

Command-Line Interface

The CLI (stone) generates code based on the provided specs, backend, and additional arguments.

Backends

There are builtin backends that come with Stone: Javascript, Python, Obj-C, Swift, and Typescript.

There are other backends we’ve written that aren’t part of the Stone package because they aren’t sufficiently general, and can’t realistically be re-used for non-Dropbox APIs: Go and Java.

Stone includes a Python interface for defining new backends based on its intermediate representation of specs. This gives you the freedom to generate to any target.

JSON Serialization

Stone defines a JSON-compatible serialization scheme.

Motivation

Stone was birthed at Dropbox at a time when it was becoming clear that API development needed to be scaled beyond a single team. The company was undergoing a large expansion in the number of product groups, and it wasn’t scalable for the API team, which traditionally dealt with core file operations, to learn the intricacies of each product and build corresponding APIs.

Stone’s chief goal is to decentralize API development and ownership at Dropbox. To be successful, it needed to do several things:

Decouple APIs from SDKS: Dropbox has first-party clients for our mobile apps, desktop client, and website. Each of these is implemented in a different language. Moreover, we wanted to continue providing SDKs to third-parties, over half of whom use our SDKs. It’s untenable to ask product groups that build APIs to also implement these endpoints in a half-dozen different language-specific SDKs. Without decoupling, as was the case in our v1 API, the SDKs will inevitably fall behind. Our solution is to have our SDKs automatically generated.

Improve Visibility into our APIs: These days, APIs aren’t just in the domain of engineering. Product managers, product specialists, partnerships, sales, and services groups all need to have clear and accurate specifications of our APIs. After all, APIs define Dropbox’s data models and functionality. Before Stone, API design documents obseleted by changes during implementation were the source of truth.

Consistency and Predictability: Consistency ranging from documentation tense to API patterns are important for making an API predictable and therefore easier to use. We needed an easy way to make and enforce patterns.

JSON: To make consumption easier for third parties, we wanted our data types to map to JSON. For cases where serialization efficiency (space and time) are important, you can try using msgpack (alpha support available in the Python generator). It’s possible also to define your own serialization scheme, but at that point, you may consider using something like Protobuf.

Stone is in active use for the Dropbox v2 API.

Assumptions

Stone makes no assumptions about the protocol layer being used to make API requests and return responses; its first use case is the Dropbox v2 API which operates over HTTP. Stone does not come with nor enforce any particular RPC framework.

Stone makes some assumptions about the data types supported in target programming languages. It’s assumed that there is a capacity for representing dictionaries (unordered string keys -> value), lists, numeric types, and strings.

Stone assumes that a route (or API endpoint) can have its argument and result types defined without relation to each other. In other words, the type of response does not change based on the input to the endpoint. An exception to this rule is afforded for error responses.

Installation

Install stone using pip:

$ pip install --user stone

This will install a script stone to your PATH that can be run from the command line:

$ stone -h

Alternative

If you choose not to install stone using the method above, you will need to ensure that you have the Python packages ply and six, which can be installed through pip:

$ pip install "ply>=3.4" "six>=1.3.0" "typing>=3.5.2"

If the stone package is in your PYTHONPATH, you can replace stone with python -m stone.cli as follows:

$ python -m stone.cli -h

If you have the stone package on your machine, but did not install it or add its location to your PYTHONPATH, you can use the following:

$ PYTHONPATH=path/to/stone python -m stone.cli -h

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stone-1.3.1.tar.gz (187.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

stone-1.3.1-py3-none-any.whl (159.7 kB view details)

Uploaded Python 3

stone-1.3.1-py2-none-any.whl (159.7 kB view details)

Uploaded Python 2

File details

Details for the file stone-1.3.1.tar.gz.

File metadata

  • Download URL: stone-1.3.1.tar.gz
  • Upload date:
  • Size: 187.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for stone-1.3.1.tar.gz
Algorithm Hash digest
SHA256 dcef72ed9b8364f8ab3a640344bbc51b4e2c7e839cad6ea66d09970eee7b8326
MD5 a3b209d8c3cb49c89a529d4eb3c81356
BLAKE2b-256 dc2c7f884ddd3cf3ad1afdb5e8f980e1850ec865d7a84015fcb363be024f77d0

See more details on using hashes here.

File details

Details for the file stone-1.3.1-py3-none-any.whl.

File metadata

  • Download URL: stone-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 159.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for stone-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7a305ad0bd0250e57b1fa2c39f0c71dcc82e7f0e259a8e3633a20d268207e109
MD5 55cbc59d020764f129da2d4bce10b90c
BLAKE2b-256 50251a786d5fc73fb2c8e1e7d47a201b4f9f950622df571f2f6954048e88da17

See more details on using hashes here.

File details

Details for the file stone-1.3.1-py2-none-any.whl.

File metadata

  • Download URL: stone-1.3.1-py2-none-any.whl
  • Upload date:
  • Size: 159.7 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/2.7.18

File hashes

Hashes for stone-1.3.1-py2-none-any.whl
Algorithm Hash digest
SHA256 68bcf6bae38ca3a8661e22554fd6a9d010dc2b41e1f7e90112aabbd05b833ac5
MD5 b7ddb4e32463be71341111153fcdec39
BLAKE2b-256 4244a06c8095354cee9383d5453dc4549e2e02434709f27c697c65fe102293d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page