Skip to content
This repository was archived by the owner on Nov 15, 2021. It is now read-only.

Add documention for API servers and RPC methods #664

Open
wants to merge 37 commits into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
13e979b
Merge pull request #38 from CityOfZion/development
jseagrave21 Oct 10, 2018
f458378
Update CHANGELOG.rst
jseagrave21 Oct 10, 2018
719a6fe
Update Readme.rst
jseagrave21 Oct 10, 2018
23ab95f
Update basicusage.rst
jseagrave21 Oct 10, 2018
76564e4
Update basicusage.rst
jseagrave21 Oct 10, 2018
4adc41a
Update basicusage.rst
jseagrave21 Oct 10, 2018
6727c3a
Create Api_Server.rst
jseagrave21 Oct 10, 2018
fed29b3
Add API_Server to toctree
jseagrave21 Oct 10, 2018
74a172b
Update Api_Server.rst
jseagrave21 Oct 10, 2018
a8da430
Update Api_Server.rst
jseagrave21 Oct 11, 2018
ae54a96
Update CHANGELOG.rst
jseagrave21 Oct 12, 2018
8346aa4
Merge pull request #42 from CityOfZion/development
jseagrave21 Oct 12, 2018
f2129fc
Delete seedlist.png
jseagrave21 Oct 12, 2018
197f286
Add seedlist.png
jseagrave21 Oct 12, 2018
62d97c4
Update Seedlist.rst
jseagrave21 Oct 12, 2018
42eaf72
Update Api_Server.rst
jseagrave21 Oct 13, 2018
792587f
Update CHANGELOG.rst
jseagrave21 Oct 13, 2018
96e7014
Update api_server.py
jseagrave21 Oct 16, 2018
34595b3
Update api_server.py
jseagrave21 Oct 16, 2018
c5567c2
Update basicusage.rst
jseagrave21 Oct 16, 2018
c4ee40a
Update basicusage.rst
jseagrave21 Oct 16, 2018
832befd
Update Seedlist.rst
jseagrave21 Oct 16, 2018
49b0e00
Update Api_Server.rst
jseagrave21 Oct 31, 2018
dcc4608
Update CHANGELOG.rst
jseagrave21 Oct 31, 2018
e005758
Merge pull request #61 from CityOfZion/development
jseagrave21 Oct 31, 2018
e5c90e7
Update CHANGELOG.rst
jseagrave21 Oct 31, 2018
24c4093
Update Api_Server.rst
jseagrave21 Nov 11, 2018
626dd99
Update basicusage.rst
jseagrave21 Nov 12, 2018
3885866
Update Api_Server.rst
jseagrave21 Nov 12, 2018
4596e30
Update api_server.py
jseagrave21 Nov 20, 2018
2f6af1c
Update CHANGELOG.rst
jseagrave21 Nov 20, 2018
0df16ff
Merge pull request #73 from CityOfZion/development
jseagrave21 Nov 20, 2018
806c20b
Update CHANGELOG.rst
jseagrave21 Nov 20, 2018
1e2f010
Update CHANGELOG.rst
jseagrave21 Nov 20, 2018
e4efd88
Update basicusage.rst
jseagrave21 Nov 20, 2018
850be72
Update basicusage.rst
jseagrave21 Nov 20, 2018
78505bd
Update Api_Server.rst
jseagrave21 Nov 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@ All notable changes to this project are documented in this file.
- Allow a raw tx to be build without an active blockchain db in the environment
- Fix unnecessary default bootstrap warning for mainnet showing.
- Add GET and OPTIONS request functionality for JSON-RPC servers
- Add documention for API servers and RPC methods


[0.8.2] 2018-10-31
2 changes: 1 addition & 1 deletion docs/Readme.rst
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ Guidelines
----------
When contributing please note the following:

1. NEO-Python Docs use the sphinx module to build https://neo-python.readthedocs.io/en/latest/. So, make sure every docucment you add uses reStructuredText (e.g. <yourfile>.rst).
1. NEO-Python Docs use the sphinx module to build https://neo-python.readthedocs.io/en/latest/. So, make sure every document you add uses reStructuredText (e.g. <yourfile>.rst).

2. After creating your document, be sure to update the ``toctree`` in index.rst. **Failing to do so will result in your document missing from the readthedocs website.**

2,753 changes: 2,753 additions & 0 deletions docs/source/Api_Server.rst

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions docs/source/Seedlist.rst
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ How do we find out which nodes are alive? Use `NEO Network Status Monitor <http:
If you would like more information visit the NEO Network Status Montior `repository <https://github.com/CityOfZion/neo-mon>`_.


.. image:: ../seedlist.png
.. image:: images/seedlist.png
:width: 400
:alt: seedlist

@@ -95,9 +95,6 @@ We follow this standard protocol for ports:
* - P2P via TCP
- 10333
- 20333
* - P2P via WebSocket
- 10334
- 20334

We will choose the first node over the third node, since *1* adheres the convention and *3* does not.

80 changes: 51 additions & 29 deletions docs/source/basicusage.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
Basic Usage
-----------
===========

There are two main ways to use neo-python: ``np-prompt`` and running just the node with custom
Introduction
------------

There are two main ways to interface with neo-python: ``np-prompt`` and running just the node with custom
code.

np-prompt
@@ -45,17 +48,18 @@ Take a look at the examples in the ``/examples`` directory: https://github.com/C

See also the sections about "Settings and Logging" and "Interacting with Smart Contracts".


API server (JSON and/or REST)
""""""""""""""""""""""""""""""
-----------------------------

Each neo-python node is capable of providing an API interface, which can be used to query the NEO Blockchain. The API interface is provided via JSON-RPC or REST, and the underlying protocol uses HTTP/HTTPS for communication. JSON-RPC and REST API servers may be run simultaneously.

Start JSON and REST API Server on Mainnet:

::

$ np-api-server --mainnet --port-rpc 10332 --port-rest 80

Example notifications plus help with all available arguments:
Example notifications:

::

@@ -67,45 +71,48 @@ Example notifications plus help with all available arguments:
[I 180315 09:27:09 _observer:131] Starting factory <twisted.web.server.Site object at 0x110619828>
[I 180315 09:27:09 np-api-server:11] Starting REST api server on http://0.0.0.0:8088

# view help
$ np-api-server -h
usage: np-api-server [-h]
View help with all available arguments:

::

$ np-api-server -h
usage: np-api-server [-h]
(--mainnet | --testnet | --privnet | --coznet | --config CONFIG)
[--port-rpc PORT_RPC] [--port-rest PORT_REST]
[--logfile LOGFILE] [--syslog] [--syslog-local [0-7]]
[--disable-stderr] [--datadir DATADIR]
[--maxpeers MAXPEERS] [--wallet WALLET] [--host HOST]

optional arguments:
-h, --help show this help message and exit
--datadir DATADIR Absolute path to use for database directories
--maxpeers MAXPEERS Max peers to use for P2P Joining
--wallet WALLET Open wallet. Will allow you to use methods that
require an open wallet
--host HOST Hostname ( for example 127.0.0.1)
-h, --help show this help message and exit
--datadir DATADIR Absolute path to use for database directories
--maxpeers MAXPEERS Max peers to use for P2P Joining
--wallet WALLET Open wallet. Will allow you to use methods that
require an open wallet
--host HOST Hostname ( for example 127.0.0.1)

Network options:
--mainnet Use MainNet
--testnet Use TestNet
--privnet Use PrivNet
--coznet Use CozNet
--config CONFIG Use a specific config file
--mainnet Use MainNet
--testnet Use TestNet
--privnet Use PrivNet
--coznet Use CozNet
--config CONFIG Use a specific config file

Mode(s):
--port-rpc PORT_RPC port to use for the json-rpc api (eg. 10332)
--port-rest PORT_REST port to use for the rest api (eg. 80)
--port-rpc PORT_RPC port to use for the json-rpc api (eg. 10332)
--port-rest PORT_REST
port to use for the rest api (eg. 80)

Logging options:
--logfile LOGFILE Logfile
--syslog Log to syslog instead of to log file ('user' is the
default facility)
--syslog-local [0-7] Log to a local syslog facility instead of 'user'.
Value must be between 0 and 7 (e.g. 0 for 'local0').
--disable-stderr Disable stderr logger

--logfile LOGFILE Logfile
--syslog Log to syslog instead of to log file ('user' is the
default facility)
--syslog-local [0-7] Log to a local syslog facility instead of 'user'.
Value must be between 0 and 7 (e.g. 0 for 'local0').
--disable-stderr Disable stderr logger

Port Description
""""""""""""""""""""""""""""""
""""""""""""""""

If you want an external program to access your API server, an open firewall port is required. The following is a port description that can be set to fully open or open-on-demand.

@@ -122,7 +129,22 @@ If you want an external program to access your API server, an open firewall port
* - JSON-RPC via HTTP
- 10332
- 20332
* - REST via HTTP
- 80
- 8080

For P2P information see `NEO-Python Seedlist <https://neo-python.readthedocs.io/en/latest/Seedlist.html>`_.

API Server Plugins
""""""""""""""""""

Default API server operation is defined in neo/Settings.py under ``DEFAULT_RPC_SERVER`` and ``DEFAULT_REST_SERVER``. Custom API server operation should be defined in the specific ``protocol.<title>.json`` being utilized. For example, to use the ExtendedJsonRpcApi update the "RPCServer" value in the corresponding ``protocol.<title>.json`` to

::

"RPCServer": "neo.api.JSONRPC.ExtendedJsonRpcApi.ExtendedJsonRpcApi"

**NOTE:** Remember to run ``python setup.py install`` after making any changes to a ``protocol.<title>.json``, so the changes take effect.

Running an API Server using Windows WSL (Ubuntu)
""""""""""""""""""""""""""""""""""""""""""""""""
File renamed without changes
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@ neo-python - Python Node and SDK for the NEO blockchain
Seedlist
basicusage
prompt
API_Server
settings-and-logging
neo/Core/TX/Transaction
neo/SmartContract/smartcontracts