Code Monkey home page Code Monkey logo

cryptoexchangebackend's Introduction

Бэкенд для криптобиржи

Данный репозиторий - это приложение, единственная цель которого - служить полем для моих экспериментов с технологиями, которые мне интересны.

Бекенд реализует авторизацию и аутентификацию с помощью JWT. Так же, агрегирует данные о ценах на биткоины и эфир, предоставляет статистику за разные промежутки времени и дает возможность виртуальной торговли.

Технологии

  • Node.js
  • express.js
  • passport.js
  • MondoDB
  • mongoose

Клиенты для данного бэкенда

Run app

npm i - npm run start

API Examples

Create new user:

curl -X POST 'http://localhost:7000/users' -d '[email protected]&password=12345678'
Response:
{"result":"created","jwt":"MY_TOKEN"}
Response:
{"result":"updated"}

Get token (sign in):

curl 'http://localhost:7000/user_token' -X POST -d '{"auth":{"email":"[email protected]","password":"12345678"}}' -H 'Content-Type: application/json'
Response:
{"jwt":"NEW_MY_TOKEN"}

Call for recent candles (offset: 'h' for hours, 'd' for days, 'w' for weeks, for example, 2d = 2 days, 8h = 8 hours):

curl 'http://localhost:7000/candles?symbol=btc&offset=2d' -H 'Authorization: Bearer TOKEN'
Result:
{"result":[{"mts":1512643020000,"sell":14460.0,"purchase":14315.4},{"mts":1512642420000,"sell":14457.0,"purchase":14312.43},...]}

User purchases btc:

curl 'http://localhost:7000/stock/exchange?symbol=btc&operation=purchase&sum=1' -H 'Authorization: Bearer TOKEN'
Result:
{"result":"changed","usd":1650.7340000000004,"btc":1.0,"eth":0.0}

User sells btc:

curl 'http://localhost:7000/stock/exchange?symbol=btc&operation=sell&sum=1' -H 'Authorization: Bearer TOKEN'
Result:
{"result":"changed","usd":9834.668,"btc":0.0,"eth":0.0}

Get user's info

curl 'http://localhost:7000/users/me' -H 'Authorization: Bearer TOKEN'
Result:
{"result":{"id":1,"email":"[email protected]","name":null,"surname":null}}

Get user's wallet info

curl 'http://localhost:7000/users/wallet' -H 'Authorization: Bearer TOKEN'
Result:
{"result":{"usd":99794679.325,"btc":3.0,"eth":0.0}}

cryptoexchangebackend's People

Contributors

ustasjs avatar

Watchers

 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.