Fork me on GitHub

A high level web API framework.

Latest : v0.1.0


Supported languages:

Forget HTTP

How do you structure URLs? Which status code do you return? How do you parse complex query parameters? Cosmic takes full responsibility for the HTTP layer, letting you focus on what's important.

Native API Clients

Your API users do not need to worry about HTTP either. Cosmic generates API clients automatically, enabling rich communication across languages. We are starting with Python, with JavaScript coming up next.


Cosmic generates documentation from your API code, which is always consistent and correct. It can be hosted along with your API, no extra work required.

1. Install cosmic-py

pip install cosmic

2. Write your functions

from cosmic.api import API
from cosmic.types import Array, Integer
from cosmic.models import BaseModel

# Name your API
mathy = API("mathy")

# Decorate your function with the parameter type and return type
@mathy.action(accepts=Array(Integer), returns=Integer)
def add(numbers):
    "Adds array of integers."
    return sum(numbers)

3. Write your models

class Polygon(BaseModel):
    properties = [
        required(u'name', String),
        required(u'points', Integer),
    # ...

4. Run the API

if __name__ == "__main__":
$ python
* Running on

5. Use the API

$ python

>>> from cosmic.api import API
>>> mathy = API.load("")
>>> mathy.actions.add([1, 2, 3, 4, 5])
>>> mathy.models.Polygon.get_list(points=3)
[<Polygon object at 0x...>]
>>> mathy.models.Polygon.get_list(points=3)[0].name

Easiest way to build your web API.

Latest : v0.1.0