Skip to main content

Client

Struct Client 

Source
pub struct Client<T: Transport = UreqTransport> { /* private fields */ }
Expand description

A HackerOne API client.

Generic over its Transport so it can be unit-tested with a mock and embedded with a custom HTTP stack. The default transport is UreqTransport.

use hackerone_api::Client;

let client = Client::new("my-api-identifier", "my-api-token");
let me = client.me()?;
println!("{:?}", me.username);

Implementations§

Source§

impl<T: Transport> Client<T>

Source

pub fn with_transport(base_url: impl Into<String>, transport: T) -> Self

Build a client over a custom transport (no credentials yet).

Source

pub fn with_credentials( self, identifier: impl Into<String>, token: impl Into<String>, ) -> Self

Attach HTTP Basic credentials (builder style).

Source

pub fn base_url(&self) -> &str

The configured base URL.

Source

pub fn me(&self) -> Result<User>

GET /v1/me — the authenticated user.

This is a customer/profile endpoint. A hacker-only API token receives 401 here; use Client::my_reports (which hits /v1/hackers/me/reports) to confirm a hacker token works.

Source

pub fn programs(&self) -> Result<Page<Program>>

GET /v1/me/programs — programs the token can access.

Source

pub fn program(&self, id: &str) -> Result<Program>

GET /v1/programs/{id} — one program by handle or id.

Source

pub fn structured_scopes( &self, program_id: &str, page: Option<(u32, u32)>, ) -> Result<Page<StructuredScope>>

GET /v1/programs/{id}/structured_scopes — a program’s scopes.

Source

pub fn reports(&self, query: &ReportQuery) -> Result<Page<Report>>

GET /v1/reports — reports, filtered by query.

Source

pub fn report(&self, id: &str) -> Result<Report>

GET /v1/reports/{id} — one report.

Source

pub fn create_report(&self, report: &CreateHackerReport) -> Result<Report>

POST /v1/hackers/reports — submit a report to a program as a hacker.

This is the endpoint a researcher uses to file a report; it posts the CreateHackerReport body (team_handle + attributes) to the hacker surface and returns the created Report.

Source

pub fn my_reports(&self, query: &PageQuery) -> Result<Page<Report>>

GET /v1/hackers/me/reports — the authenticated hacker’s own reports.

Source

pub fn my_report(&self, id: &str) -> Result<Report>

GET /v1/hackers/reports/{id} — one of the authenticated hacker’s reports.

Source

pub fn hacktivity(&self, query: &HacktivityQuery) -> Result<Page<Hacktivity>>

GET /v1/hackers/hacktivity — the public hacktivity feed.

query.query_string is a Lucene filter, e.g. severity_rating:critical AND disclosed:true.

Source

pub fn balance(&self) -> Result<Balance>

GET /v1/hackers/payments/balance — the authenticated hacker’s balance.

Source

pub fn earnings(&self, query: &PageQuery) -> Result<Page<Earning>>

GET /v1/hackers/payments/earnings — the authenticated hacker’s earnings.

Source

pub fn add_comment( &self, report_id: &str, message: &str, ) -> Result<Resource<Value>>

POST /v1/reports/{id}/activities — add a comment.

Source

pub fn change_state( &self, report_id: &str, state: ReportState, message: Option<&str>, ) -> Result<Resource<Value>>

POST /v1/reports/{id}/state_changes — change a report’s state.

Source

pub fn weaknesses(&self) -> Result<Page<Weakness>>

GET /v1/weaknesses — the CWE catalog.

Source

pub fn next_page<A: DeserializeOwned + Default>( &self, page: &Page<A>, ) -> Result<Option<Page<A>>>

Fetch the next page from a next link returned by a previous call.

Source

pub fn get_raw(&self, path: &str, query: &[(String, String)]) -> Result<Value>

Escape hatch: a raw authenticated GET returning the parsed body.

Source§

impl Client<UreqTransport>

Source

pub fn new(identifier: impl Into<String>, token: impl Into<String>) -> Self

A client with the default transport and credentials.

Source

pub fn anonymous() -> Self

A client with the default transport and no credentials (public reads).

Auto Trait Implementations§

§

impl<T> Freeze for Client<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Client<T>
where T: RefUnwindSafe,

§

impl<T> Send for Client<T>

§

impl<T> Sync for Client<T>

§

impl<T> Unpin for Client<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Client<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Client<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.