Documentation Index
Fetch the complete documentation index at: https://docs.benzinga.com/llms.txt
Use this file to discover all available pages before exploring further.
개발자 친화적이며 타입 안정성이 보장되는 Java SDK로, openapi API를 활용하기에 최적화되어 있습니다.
Benzinga APIs: 이 REST API는 모든 Benzinga API에 접근하기 위한 엔드포인트를 제공합니다.
JDK 11 이상이 필요합니다.
아래 예제는 배포된 SDK 아티팩트를 사용하는 방법을 보여줍니다:
Gradle:
implementation 'org.benzinga:BZClient:0.2.7'
Maven:
<dependency>
<groupId>org.benzinga</groupId>
<artifactId>BZClient</artifactId>
<version>0.2.7</version>
</dependency>
git 저장소를 로컬 파일 시스템에 클론한 후, *nix 시스템에서는 ./gradlew build를, Windows 시스템에서는 gradlew.bat를 실행하여 소스에서 SDK 아티팩트를 build 디렉터리로 빌드할 수 있습니다.
소스에서 빌드하고 SDK 아티팩트를 로컬 Maven 저장소(로컬 파일 시스템)에 게시하려면, git 저장소를 로컬에 클론한 뒤 다음 명령을 사용하십시오:
*nix에서:
./gradlew publishToMavenLocal -Pskip.signing
Windows에서는:
gradlew.bat publishToMavenLocal -Pskip.signing
package hello.world;
import java.lang.Exception;
import org.benzinga.BZClient.Bzclient;
import org.benzinga.BZClient.models.operations.GetAnalystReportsRawTextDataResponse;
public class Application {
public static void main(String[] args) throws Exception {
Bzclient sdk = Bzclient.builder()
.apiKeyAuth("<YOUR_API_KEY_HERE>")
.build();
GetAnalystReportsRawTextDataResponse res = sdk.analystReportsRawText().get()
.page(700347L)
.pagesize(558834L)
.call();
if (res.modelsAnalystReportRawTexts().isPresent()) {
// 응답 처리
}
}
}
이 SDK는 전역적으로 다음 보안 스키마를 지원합니다:
| Name | Type | Scheme |
|---|
apiKeyAuth | apiKey | API key |
API에 인증하려면 SDK 클라이언트 인스턴스를 초기화할 때 apiKeyAuth 파라미터를 설정해야 합니다. 예시는 다음과 같습니다:
package hello.world;
import java.lang.Exception;
import org.benzinga.BZClient.Bzclient;
import org.benzinga.BZClient.models.operations.GetAnalystReportsRawTextDataResponse;
public class Application {
public static void main(String[] args) throws Exception {
Bzclient sdk = Bzclient.builder()
.apiKeyAuth("<YOUR_API_KEY_HERE>")
.build();
GetAnalystReportsRawTextDataResponse res = sdk.analystReportsRawText().get()
.page(700347L)
.pagesize(558834L)
.call();
if (res.modelsAnalystReportRawTexts().isPresent()) {
// 응답 처리
}
}
}
- get - 애널리스트 리포트 원문 텍스트 데이터 조회
- get - Bulls Say Bears Say V1 가져오기
- getV22 - 배당금 V2.2 가져오기
- get - 배당금 V2 및 V2.1 가져오기
- 가져오기 - earning ratios v2.1 가져오기
- 가져오기 - Insider Transaction 가져오기
- get - Newsquantified 데이터 가져오기
- get - OptionActivity V1 가져오기
- get - Ratings Analysts 가져오기
- get - Removed 데이터 가져오기 (v2)
- get - 티커 트렌드 데이터 가져오기
- getList - 티커 트렌드 목록 데이터 가져오기
- get - Valuation Ratios v2.1 가져오기
이 SDK의 일부 엔드포인트는 재시도를 지원합니다. 별도의 설정 없이 SDK를 사용할 경우, API에서 제공하는 기본 재시도 전략이 사용됩니다. 하지만 기본 재시도 전략은 개별 작업별로 또는 SDK 전체에 대해 재정의할 수 있습니다.
단일 API 호출에 대한 기본 재시도 전략을 변경하려면 retryConfig 빌더 메서드를 통해 RetryConfig 객체를 제공하면 됩니다:
package hello.world;
import java.lang.Exception;
import java.util.concurrent.TimeUnit;
import org.benzinga.BZClient.Bzclient;
import org.benzinga.BZClient.models.operations.GetAnalystReportsRawTextDataResponse;
import org.benzinga.BZClient.utils.BackoffStrategy;
import org.benzinga.BZClient.utils.RetryConfig;
public class Application {
public static void main(String[] args) throws Exception {
Bzclient sdk = Bzclient.builder()
.apiKeyAuth("<YOUR_API_KEY_HERE>")
.build();
GetAnalystReportsRawTextDataResponse res = sdk.analystReportsRawText().get()
.retryConfig(RetryConfig.builder()
.backoff(BackoffStrategy.builder()
.initialInterval(1L, TimeUnit.MILLISECONDS)
.maxInterval(50L, TimeUnit.MILLISECONDS)
.maxElapsedTime(1000L, TimeUnit.MILLISECONDS)
.baseFactor(1.1)
.jitterFactor(0.15)
.retryConnectError(false)
.build())
.build())
.page(700347L)
.pagesize(558834L)
.call();
if (res.modelsAnalystReportRawTexts().isPresent()) {
// 응답 처리
}
}
}
재시도를 지원하는 모든 작업에 대한 기본 재시도 전략을 재정의하려면, SDK 초기화 시 설정을 제공하면 됩니다:
package hello.world;
import java.lang.Exception;
import java.util.concurrent.TimeUnit;
import org.benzinga.BZClient.Bzclient;
import org.benzinga.BZClient.models.operations.GetAnalystReportsRawTextDataResponse;
import org.benzinga.BZClient.utils.BackoffStrategy;
import org.benzinga.BZClient.utils.RetryConfig;
public class Application {
public static void main(String[] args) throws Exception {
Bzclient sdk = Bzclient.builder()
.retryConfig(RetryConfig.builder()
.backoff(BackoffStrategy.builder()
.initialInterval(1L, TimeUnit.MILLISECONDS)
.maxInterval(50L, TimeUnit.MILLISECONDS)
.maxElapsedTime(1000L, TimeUnit.MILLISECONDS)
.baseFactor(1.1)
.jitterFactor(0.15)
.retryConnectError(false)
.build())
.build())
.apiKeyAuth("<YOUR_API_KEY_HERE>")
.build();
GetAnalystReportsRawTextDataResponse res = sdk.analystReportsRawText().get()
.page(700347L)
.pagesize(558834L)
.call();
if (res.modelsAnalystReportRawTexts().isPresent()) {
// 응답 처리
}
}
}
이 SDK에서의 오류 처리는 전반적으로 예상하는 방식과 크게 다르지 않습니다. 모든 오퍼레이션은 응답 객체를 반환하거나 예외를 던집니다.
기본적으로 API 오류는 models/errors/APIException 예외를 던집니다. 오퍼레이션에 대해 사용자 정의 오류 응답이 지정된 경우, SDK는 그에 연관된 예외를 추가로 던질 수 있습니다. 각 오퍼레이션에서 발생할 수 있는 예외 타입에 대한 자세한 내용은 SDK 문서의 해당 오류 표를 참조하십시오. 예를 들어, get 메서드는 다음 예외를 던집니다:
| 오류 타입 | 상태 코드 | 콘텐츠 유형 |
|---|
| models/errors/ApiErrorResponse | 400, 500 | application/json |
| models/errors/APIException | 4XX, 5XX | / |
package hello.world;
import java.lang.Exception;
import org.benzinga.BZClient.Bzclient;
import org.benzinga.BZClient.models.errors.ApiErrorResponse;
import org.benzinga.BZClient.models.operations.GetAnalystInsightsV1Request;
import org.benzinga.BZClient.models.operations.GetAnalystInsightsV1Response;
public class Application {
public static void main(String[] args) throws ApiErrorResponse, Exception {
Bzclient sdk = Bzclient.builder()
.apiKeyAuth("<YOUR_API_KEY_HERE>")
.build();
GetAnalystInsightsV1Request req = GetAnalystInsightsV1Request.builder()
.build();
GetAnalystInsightsV1Response res = sdk.analystInsights().get()
.request(req)
.call();
if (res.modelsAnalystInsightsJSON().isPresent()) {
// 응답 처리
}
}
}
SDK 클라이언트 인스턴스를 초기화할 때 .serverIndex(int serverIdx) 빌더 메서드를 사용하여 전역 기본 서버를 재정의할 수 있습니다. 선택한 서버는 해당 서버를 사용하는 오퍼레이션의 기본값으로 사용됩니다. 다음 표는 사용 가능한 서버에 대응하는 인덱스를 보여줍니다:
| # | Server |
|---|
| 0 | https://api.benzinga.com |
| 1 | https://api.benzinga.com/api/v1 |
| 2 | https://api.benzinga.com/api/v2 |
| 3 | https://api.benzinga.com/api/v2.1 |
| 4 | https://api.benzinga.com/api/v2.2 |
package hello.world;
import java.lang.Exception;
import org.benzinga.BZClient.Bzclient;
import org.benzinga.BZClient.models.operations.GetAnalystReportsRawTextDataResponse;
public class Application {
public static void main(String[] args) throws Exception {
Bzclient sdk = Bzclient.builder()
.serverIndex(4)
.apiKeyAuth("<YOUR_API_KEY_HERE>")
.build();
GetAnalystReportsRawTextDataResponse res = sdk.analystReportsRawText().get()
.page(700347L)
.pagesize(558834L)
.call();
if (res.modelsAnalystReportRawTexts().isPresent()) {
// 응답 처리
}
}
}
기본 서버는 SDK 클라이언트 인스턴스를 초기화할 때 .serverURL(String serverUrl) 빌더 메서드를 사용하여 전역적으로 재정의할 수도 있습니다. 예를 들어:
package hello.world;
import java.lang.Exception;
import org.benzinga.BZClient.Bzclient;
import org.benzinga.BZClient.models.operations.GetAnalystReportsRawTextDataResponse;
public class Application {
public static void main(String[] args) throws Exception {
Bzclient sdk = Bzclient.builder()
.serverURL("https://api.benzinga.com")
.apiKeyAuth("<YOUR_API_KEY_HERE>")
.build();
GetAnalystReportsRawTextDataResponse res = sdk.analystReportsRawText().get()
.page(700347L)
.pagesize(558834L)
.call();
if (res.modelsAnalystReportRawTexts().isPresent()) {
// 응답 처리
}
}
}
이 SDK는 베타 단계에 있으며, 메이저 버전 업데이트 없이도 버전 간에 호환성이 깨지는 변경 사항이 발생할 수 있습니다. 따라서 특정 패키지 버전에 고정해서 사용하는 것을 권장합니다. 이렇게 하면, 의도적으로 최신 버전을 사용하려는 경우가 아니라면 매번 동일한 버전을 설치하면서 호환성 문제를 피할 수 있습니다.
이 SDK에 대한 오픈 소스 기여는 감사히 여기지만, 이 라이브러리는 프로그램을 통해 자동 생성되는 라이브러리입니다. 내부 파일에 수동으로 추가된 변경 사항은 다음 번 생성 시 모두 덮어씌워집니다.
여러분의 피드백을 기다리고 있습니다. Proof of Concept(POC)가 포함된 PR 또는 issue를 자유롭게 생성해 주시면, 향후 릴리스에 반영할 수 있도록 최선을 다하겠습니다.