Skip to content

Zyla-Labs/metals-java-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Metals-API Java Client

Official Java client for the Metals-API.

Installation (via JitPack)

Para Gradle

  1. Add the JitPack repository:
// build.gradle
repositories {
    mavenCentral()
    maven { url 'https://jitpack.io' }
}
  1. Add dependency:
dependencies {
    implementation 'com.github.Zyla-Labs:metals-api-java-client:0.1.0'
}

Para Maven

  1. Add the JitPack repository:
<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
  1. Add dependency:
<dependency>
    <groupId>com.github.Zyla-Labs</groupId>
    <artifactId>metals-api-java-client</artifactId>
    <version>0.1.0</version>
</dependency>

Nota: Reemplaza Zyla-Labs con tu usuario/organización de GitHub y metals-api-java-client con el nombre de tu repositorio.

Publicar en JitPack

Para publicar este SDK en JitPack:

  1. Sube el código a GitHub:

    git init
    git add .
    git commit -m "Initial commit"
    git remote add origin https://github.com/TU-USUARIO/metals-api-java-client.git
    git push -u origin main
  2. Crea un tag de versión:

    git tag 0.1.0
    git push origin 0.1.0
  3. JitPack construirá automáticamente el proyecto. Puedes verificar el build en:

    https://jitpack.io/#TU-USUARIO/metals-api-java-client/0.1.0
    
  4. Usa la dependencia con el formato:

    com.github.TU-USUARIO:metals-api-java-client:0.1.0
    

Usage

import com.metals.api.MetalsClient;

public class Example {
    public static void main(String[] args) {
        MetalsClient client = new MetalsClient("YOUR_ACCESS_KEY");
        
        var latest = client.getLatest("USD", "RICE,WHEAT,SUGAR");
        System.out.println(latest);
        
        var historical = client.getHistorical("2024-05-15", "USD", "WTIOIL,GOLD");
        System.out.println(historical);
    }
}

Methods

  • getLatest(base, symbols)
  • getHistorical(date, base, symbols)
  • getTimeSeries(startDate, endDate, base, symbols)
  • getFluctuation(startDate, endDate, base, symbols)
  • convert(from, to, amount, date)
  • getSymbols()
  • getSeasonality(symbol, groupBy, years) (cuando el endpoint exista)

Error handling

import com.metals.api.MetalsClient;
import com.metals.api.MetalsApiException;

try {
    var client = new MetalsClient("YOUR_ACCESS_KEY");
    var latest = client.getLatest("USD", "WTIOIL,GOLD");
} catch (MetalsApiException e) {
    System.err.println(e.getMessage());
    System.err.println("Status: " + e.getStatusCode());
    System.err.println("Code: " + e.getErrorCode());
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors