Ir para conteúdo
  • Cadastre-se

L2jRest - An L2j Rest API


Posts recomendados

L2jRest is a RESTful API for L2j

It is created for latest aCis but you should be able to adapt it is you wanna use it for other projects.

L2jRest is an open source project licensed under MIT. You can find the source here: 

O conteúdo está oculto, favor efetuar login ou se cadastrar!

Why use it?

  • You can use the data of your server in your website
  • You can create an account control panel with it
  • You can expose data to your community to allow them to make third party apps

Technical stuff

  • It is written in Kotlin.
  • It is using the Ktor framework. Ktor is using coroutines to achieve asynchronous request handling. It is very efficient and very fast.
  • It is using Netty as the underlying server.
  • It is written in a CQRS manner with query handlers for get endpoints and command handlers for post, put, patch, delete etc.
  • It is using Koin as the IoC framework.

How to setup

  • Download and install Intellij IDEA
  • Git clone the project and open it with Intellij
  • Run the build Gradle task. It is configured to create a fat jar with all the dependencies included
  • Paste the jar in your project, add it in your classpath and add the following line at the bottom of your Gameserver.java: L2jRestApi.INSTANCE.start();
  • Running the gameserver will also run the api. It is running under port 6969

How to extend it

  • All you need to do if you wanna add more endpoints is to add a new handler and then add the Get, Post etc annotation depending on what endpoint you want this to be.

 

Current endpoints:

http://localhost:6969/api/players
http://localhost:6969/api/players
/{id}

A couple of endpoint examples

Endpoints: http://localhost:6969/api/players

Response:

O conteúdo está oculto, favor efetuar login ou se cadastrar!

 

Endpoint: http://localhost:6969/api/players/268480927

Response:

O conteúdo está oculto, favor efetuar login ou se cadastrar!

 

Currently it just supports two endpoints and no authentication. I am planning to add more endpoints and ApiKey based auth tomorrow.

If you can't be arsed to build the project yourself but you wanna take a look anyway you can download the jar

O conteúdo está oculto, favor efetuar login ou se cadastrar!

Editado por Elfocrash
  • Gostei 4
  • Amei 1
Link para o comentário
Compartilhar em outros sites


8 minutos atrás, Elfocrash disse:

I don't know whats nWatch. Can you give me an example?

O conteúdo está oculto, favor efetuar login ou se cadastrar!

You are able to see status/equipment/etc of any player. Just putting the nickname.

Sry for not having an online example.

Editado por PeNaChO

QdeQ9Kp.png

Link para o comentário
Compartilhar em outros sites

Thanks guys.

Changed the way handlers are registered. Now they will be scanned automatically during server startup and they will be registered based on their annotation. This means that all you have to do to add a new endpoint is to create a request handler and add the Get, Post etc annotation.

Link para o comentário
Compartilhar em outros sites

  • L2JBr ADM

Nice work!

 

I never read nothing about this language, I need to look at it for sure!

If it was to PHP I have a perfect library to implement cross  revision support 

O conteúdo está oculto, favor efetuar login ou se cadastrar!
 (not mature yet but could be with some help)

?

 

EJoOSOj.gif

Sua pergunta foi respondida? Certifique-se de marcar a resposta como a solução aceita.
Se existe mais de uma resposta, utilize o "vote up" para destacá-la.
Se você achar uma resposta útil, diga obrigado clicando no botão "Gostei".

Link para o comentário
Compartilhar em outros sites

16 hours ago, Grundor said:

I never read nothing about this language, I need to look at it for sure!

If it was to PHP I have a perfect library to implement cross  revision support 

O conteúdo está oculto, favor efetuar login ou se cadastrar!
 (not mature yet but could be with some help)

?

 

It's very good. It's like a way better java (combines C#, Scala and Java) and it has proper async support with coroutines. This API is insanely fast.

I've seen the l2jphp. It is quite different since L2jRest runs from within the server to provide real time metrics. L2jphp goes straight to the database right?

Update

  • Added api key based authentication as requested. Requests will only be served when the x-api-key header is set with the configured value.
Link para o comentário
Compartilhar em outros sites

  • L2JBr ADM
18 minutos atrás, Elfocrash disse:

It's very good. It's like a way better java (combines C#, Scala and Java) and it has proper async support with coroutines. This API is insanely fast.

I've seen the l2jphp. It is quite different since L2jRest runs from within the server to provide real time metrics. L2jphp goes straight to the database right?

Update

  • Added api key based authentication as requested. Requests will only be served when the x-api-key header is set with the configured value.

Yes, its most to the php+mysql envs such remote websites and something like that.

 

For sure an internal API running among the server will be insanely fast, a build-in server with an HTTP API would be very nice for development. 

EJoOSOj.gif

Sua pergunta foi respondida? Certifique-se de marcar a resposta como a solução aceita.
Se existe mais de uma resposta, utilize o "vote up" para destacá-la.
Se você achar uma resposta útil, diga obrigado clicando no botão "Gostei".

Link para o comentário
Compartilhar em outros sites

  • 2 months later...
  • Registre-se

    Faça parte da maior e  mais antigas comunidades sobre Lineage2 da América Latina.





×
×
  • Criar Novo...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.