项目作者: infostellarinc

项目描述 :
The API definition for StellarStation.
高级语言: Mako
项目地址: git://github.com/infostellarinc/stellarstation-api.git
创建时间: 2018-05-22T08:28:47Z
项目社区:https://github.com/infostellarinc/stellarstation-api

开源协议:Apache License 2.0

下载


StellarStation API

The public API definition for StellarStation and supported client
libraries / helpers.

Feel free to send PRs to improve documentation when things are unclear or file issues with questions on usage.

Usage

The StellarStation API is based on gRPC. An API client can be written in any
language supported by gRPC by following one of the language-specific guides here.

The main protocol definition used to generate language specific stub code is here.

Language-specific documentation:

When using proto files from this repository directly in client code, make sure to only use tagged releases.
Using proto files from any non-tagged revision will likely not work correctly or maintain backwards compatibility.

The API follows semantic versioning - any breaking, backwards incompatible change will be made while increasing the
major version.

Java

We provide precompiled client stubs for Java. Java users can just add a dependency on
the stubs and don’t need to compile the protocol into code themselves.

Gradle users should add the stellarstation-api artifact to their dependencies, e.g.,

  1. dependencies {
  2. compile 'com.stellarstation.api:stellarstation-api:0.14.0'
  3. }

Maven users would add to their pom.xml

  1. <dependencies>
  2. <dependency>
  3. <groupId>com.stellarstation.api</groupId>
  4. <artifactId>stellarstation-api</artifactId>
  5. <version>0.14.0</version>
  6. </dependency>
  7. </dependencies>

A full example of a Java API client can be found here.
You can also find tutorials to start your own Java client here.

We publish SNAPSHOT builds to https://oss.sonatype.org/content/repositories/snapshots for access
to preview features. The same caveats as using non-tagged releases applies - not all functions in
SNAPSHOT builds may be implemented yet and there is no guarantee of backwards compatibility for
SNAPSHOT builds. It is generally not recommended to use SNAPSHOT builds without first consulting
with your StellarStation rep.

Note for Alpine Linux users

For anyone trying to use the Java API client in an Alpine Linux container, they will find it doesn’t
work due to a limitation of gRPC with Java 8. There are many ways to work around this, such as
using jetty-alpn or
installing a version of Java 9+, but our recommendation for Java 8 users is to use
distroless, which
is similarly compact but will work fine with gRPC.

Python

We provide precompiled client stubs for Python. Python users can install them with pip.

  1. $ pip install --upgrade stellarstation

A full example of a Python API client can be found here.

Go

We provide precompiled client stubs for Go, found here.

  1. import stellarstation "github.com/infostellarinc/go-stellarstation/api/v1"

NodeJS

We provide precompiled client stubs for NodeJS. NodeJS users can install them with npm.

  1. $ npm install @infostellarinc/stellarstation-api

Authentication

Authentication to the StellarStation API is done using JWT bearer tokens (https://jwt.io). When
initializing an API client, make sure to register call credentials using the private key downloaded
from the StellarStation Console. Details for registering call credentials on a gRPC stub can be
found here. Note that if the key has been revoked on the
console, it will not be usable to authenticate with the API.

Java

For Java, the grpc-auth and google-auth-library-oauth2-http libraries can be used to easily setup
authentication of an API client.

  1. // Load the private key downloaded from the StellarStation Console.
  2. ServiceAccountJwtAccessCredentials credentials =
  3. ServiceAccountJwtAccessCredentials.fromStream(
  4. Resources.getResource("stellarstation-private-key.json").openStream(),
  5. URI.create("https://api.stellarstation.com"));
  6. // Setup the gRPC client.
  7. ManagedChannel channel =
  8. ManagedChannelBuilder.forAddress("api.stellarstation.com", 443)
  9. .build();
  10. StellarStationServiceStub client =
  11. StellarStationServiceGrpc.newStub(channel)
  12. .withCallCredentials(MoreCallCredentials.from(credentials));

Python

google-auth for Python can be used for authentication of an API client.

  1. # Load the private key downloaded from the StellarStation Console.
  2. credentials = google_auth_jwt.Credentials.from_service_account_file(
  3. 'stellarstation-private-key.json',
  4. audience='https://api.stellarstation.com')
  5. # Setup the gRPC client.
  6. jwt_creds = google_auth_jwt.OnDemandCredentials.from_signing_credentials(
  7. credentials)
  8. channel = google_auth_transport_grpc.secure_authorized_channel(
  9. jwt_creds, None, 'api.stellarstation.com:443')
  10. client = stellarstation_pb2_grpc.StellarStationServiceStub(channel)

Other languages

Other languages have similar methods for loading Service Account JWT Access Credentials.
For example,