GithubHelp home page GithubHelp logo

cryptosheet's Introduction

Crypto Sheet API server

This server exposes a subset of Redis database commands to the client, and allows clients to evaluate javascripts in sandboxes (with crypto, lodash, and ethers.js libraries included), upload files, call APIs, or retrieve resources from the web. This enables a spreadsheet client to experiment with advanced spreadsheet functionalities as cell formula without being limited by CORS restrictions by browsers, or delays in blockchain transactions.

APIs

Get key or resources from database

GET /:key

Response:

If key ends with :file, the resource is retrieved as a binary buffer from the database, and the response will include its mime-type in the response header content-type. Otherwise, the value is retrieved as a string and returned in JSON:

{"value": "123"}

Set key and a string value

POST /a/basic
{
    "key": "test",
    "value": "111"
}

Response:

The redis database's response to the set command. key must match /^[a-zA-Z0-9\-_]+$/ and cannot be a or health.

{
    "response": "OK"
}

Delete a key and its value

DELETE /a/basic?key=test

Response:

The redis database's response to the delete command

{
    "response": "OK"
}

Execute a redis command

Support commands are: COPY, DEL, GET, SET, EXISTS, EXPIRE, MOVE, TOUCH, RENAME, HDEL, HEXISTS, HGET, HGETALL, HINCRBY, HINCRBYFLOAT, HKEYS, HLEN, HMGET, HMSET, HRANDFIELD, HSCAN, HSET, HSETNX, HSTRLEN, HVALS, SADD, SCARD, SDIFF, SDIFFSTORE, SINTER, SINTERCARD, SINTERSTORE, SISMEMBER, SMEMBERS, SMISMEMBER, SMOVE, SPOP, SRANDMEMBER, SREM, SSCAN, SUNION, SUNIONSTORE, ZADD, ZCARD, ZCOUNT, ZDIFF, ZDIFFSTORE, ZINCRBY, ZINTER, ZINTERCARD, ZINTERSTORE, ZLEXCOUNT, ZMPOP, ZMSCORE, ZPOPMAX, ZPOPMIN, ZRANDMEMBER, ZRANGE, ZRANGEBYLEX, ZRANGEBYSCORE, ZRANGESTORE, ZRANK, ZREM, ZREMRANGEBYLEX, ZREMRANGEBYRANK, ZREMRANGEBYSCORE, ZREVRANGE, ZREVRANGEBYLEX, ZREVRANGEBYSCORE, ZREVRANK, ZSCAN, ZSCORE, ZUNION, ZUNIONSTORE, PFADD, PFCOUNT, PFDEBUG, PFMERGE, PFSELFTEST, GEOADD, GEODIST, GEOHASH, GEOPOS, GEORADIUS, GEORADIUS_RO, GEORADIUSBYMEMBER, GEORADIUSBYMEMBER_RO, GEOSEARCH, GEOSEARCHSTORE, APPEND, DECR, DECRBY, GET, GETDEL, GETEX, GETRANGE, GETSET, INCR, INCRBY, INCRBYFLOAT, LCS, MGET, MSET, MSETNX, PSETEX, SET, SETEX, SETNX, SETRANGE, STRLEN, SUBSTR

POST /a/cmd
{
    "cmd": "HSET",
    "args": ["testset", "field1", "value1"]
}

Response:

The redis database's response to the delete command

{
    "response": "OK"
}

Fetch a remote resource via HTTP GET

GET /a/get?https://google.com

Response:

{
    "data": "....",
    "status": 200,
    "statusText": "OK",
    "headers": {...}
}

Call a remote API via an HTTP method

POST /a/url
{
    "url": "https://google.com",
    "method": "get",
    "body": {...},
    "headers": {...}
}

Response:

{
    "data": "....",
    "status": 200,
    "statusText": "OK",
    "headers": {...}
}

Evaluate a simple javascript in a sandbox

GET /a/eval?1+1

Response:

{
    "result": 2
}
GET /eval?lodash.uniq([1,1,2,3,1])

Response:

{
    "result": [
        1,
        2,
        3
    ]
}

Evaluate a complex javascript in a sandbox

POST /a/eval
{
    "script": "ethers.Wallet.createRandom().privateKey",
    "timeout": 100,
    "useEthers": true
}

Here, useEthers and timeout (in ms) are optional. If useEthers is true, a fresh instance of ethers.js v5.6 library is loaded dynamically, which may slow down the response time. timeout cannot be more than 30 seconds

Response:

{
    "result": "0x0ce9f8ba9756fdd0db2fb89db1abdbd92a9014321e94d3c18c766796307e9e32"
}

Upload a file

POST /a/upload
content-type: multipart/form-data
fields:
- key: satoshi-html:file
- file: ...

Here, the key must ends with :file, and the uploaded file should be attached to file field.

key must match /^[a-zA-Z0-9\-_]+$/ and cannot be a or health.

Response:

{
    "response": "OK",
    "mimetype": "text/html",
    "originalname": "Google.html",
    "size": 143870
}

Internally, the mime-type of the file is stored at key <key>:mimetype. In the example above, the mime-type is stored at satoshi-html:file:mimetype

cryptosheet's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.