PS2.API (PlanetSide 2 API v1.0.0)

View Source

Functions for querying the Census API.

Use query/1 to get data from the Census.

iex> q = PS2.API.Query.new(collection: "character_name")
...> |> PS2.API.QueryBuilder.term("name.first_lower", "snowful")
%PS2.API.Query{
  collection: "character_name",
    joins: [],
    params: %{"name.first_lower" => {"", "snowful"}},
  sort: nil,
  tree: nil
}
iex> PS2.API.query(q, "example")
{:ok,
  %PS2.API.QueryResult{
    data: [
      %{
        "character_id" => "5428713425545165425",
        "name" => %{"first" => "Snowful", "first_lower" => "snowful"}
      }
    ],
  returned: 1
 }
}

Summary

Functions

Gets a list of all the public API collections and their resolves.

Gets the image binary for a .png.

Sends query to the Census API, returning {:ok, %QueryResult{}} struct on success. req_opts is a keyword list of Req opts.

Sends query to the API and returns the first result if successful.

Functions

census_endpoint(sid \\ "example")

get_collections(service_id, req_opts \\ [], endpoint_fxn \\ &census_endpoint/1)

Gets a list of all the public API collections and their resolves.

get_image(image_path, endpoint \\ census_endpoint())

@spec get_image(String.t(), String.t()) :: {:ok, binary()} | {:error, Exception.t()}

Gets the image binary for a .png.

get_image_url(image_path, endpoint \\ census_endpoint())

@spec get_image_url(String.t(), String.t()) :: String.t()

Gets the URL for an image.

query(query, service_id, req_opts \\ [], endpoint_fxn \\ &census_endpoint/1)

@spec query(PS2.API.Query.t(), String.t(), Keyword.t(), (service_id :: String.t() ->
                                                     String.t())) ::
  {:ok, PS2.API.QueryResult.t()} | {:error, PS2.API.Error.t() | Exception.t()}

Sends query to the Census API, returning {:ok, %QueryResult{}} struct on success. req_opts is a keyword list of Req opts.

query_one(query, service_id, req_opts \\ [], endpoint_fxn \\ &census_endpoint/1)

@spec query_one(PS2.API.Query.t(), String.t(), Keyword.t(), (service_id :: String.t() ->
                                                         String.t())) ::
  {:ok, PS2.API.QueryResult.t()} | {:error, PS2.API.Error.t() | Exception.t()}

Sends query to the API and returns the first result if successful.