Skip to content

ESI.Sharp is an unofficial .NET API Wrapper for the EVE Online ESI (https://esi.evetech.net/ui) with powerfully commented endpoints and testing as much as possible

License

Notifications You must be signed in to change notification settings

TheBottleCyber/ESI.Sharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.NET Sonar Scanner Quality Gate Status Maintainability Rating Reliability Rating Security Rating NuGet

What is ESI.Sharp

ESI.Sharp is an unofficial .NET API Wrapper for the EVE Online ESI (https://esi.evetech.net/ui) with powerfully commented endpoints, models and enumerations

Resources

Install

You can install ESI.Sharp as a nuget package:
dotnet add package ESI.Sharp

ESI.Sharp is a .NET Standard 2.0 Library with support for .NET Core 5.0+

Usage

You can instantiate the client in this manner:

var esiConfig = new EsiConfig(clientId: "*******", secretKey: "*******", callbackUrl: "", userAgent: "");
var esiClient = new EsiClient(esiConfig);

For your protection (and mine), you are required to supply a userAgent value. This can be your character name and/or project name. CCP will be more likely to contact you than just cut off access to ESI if you provide something that can identify you within the New Eden galaxy. Without this property populated, the wrapper will not work.

Status public endpoint example

Accessing a public endpoint is extremely simple:

var status = await esiClient.Status.Retrieve();
var statusJsoned = JsonConvert.SerializeObject(status);

Console.WriteLine(statusJsoned);

And it will print EsiResponse object to console output:

{
  "RequestId": "e26f94ed-03ae-4d82-8bc8-ba68f357b2a5",
  "StatusCode": 200,
  "Expires": "2022-02-21T01:45:04Z",
  "LastModified": "2022-02-21T01:44:34Z",
  "ETag": "60f0724159e0f94524abc3abcd8ffda1ba5bb2079e64de28b32aa659",
  "ErrorLimitRemain": 100,
  "ErrorLimitReset": 18,
  "Pages": null,
  "Message": null,
  "Data": {
    "players": 18024,
    "server_version": "2003445",
    "start_time": "2022-02-20T11:01:33Z",
    "vip": false
  },
  "Exception": null
}

SSO Authorization

SSO Login URL generator

ESI.Sharp has method to generate the URL required to authenticate a character or authorize roles (by providing a params of scopes) for the ESI API.

You should also provide a value for state that you verify when it is returned (it will be included in the callback).

Without scopes (only public endpoints will available):

var authUrl = esiClient.Authorization.CreateAuthorizationUrl("custom_state");

With all scopes (all authorized endpoints will available):

var allScopes = EnumHelper.GetEnumValues<Scope>();
var authUrl = esiClient.Authorization.CreateAuthorizationUrl("custom_state", allScopes.ToArray());

With custom scopes params (only allowed by scope endpoints will available):

var authUrl = esiClient.Authorization.CreateAuthorizationUrl("custom_state",
 Scope.UIOpenWindow, Scope.AssetsReadAssets, Scope.CharactersReadTitles, ...);

Initial SSO token request

var token = await esiClient.Authorization.GetToken(TokenGrantType.AuthorizationCode, response_code);
var validatedToken = await client.Authorization.ValidateToken(token);

Refresh SSO token

var token = await esiClient.Authorization.GetToken(TokenGrantType.RefreshToken, refresh_token);

Performing an authenticated request

Set the validated token data on the client before performing the request

esiClient.SetRequestToken(validatedToken);

About

ESI.Sharp is an unofficial .NET API Wrapper for the EVE Online ESI (https://esi.evetech.net/ui) with powerfully commented endpoints and testing as much as possible

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages