View Source PS2.API (PlanetSide 2 API v0.3.4)

Your gateway to 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
 }
}

Link to this section Summary

Functions

Encodes a Query struct into an API-ready string.

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

Gets the image binary for a .png.

Gets the image link.

Sends query to the API and returns a list of results if successful. service_id is the Census service_id with which the query will be sent. opts is a keyword list of HTTPoison opts.

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

Link to this section Functions

Specs

encode(PS2.API.Query.t()) ::
  {:ok, String.t()} | {:error, PS2.API.Query.Error.t()}

Encodes a Query struct into an API-ready string.

Link to this function

get_collections(service_id)

View Source

Specs

get_collections(String.t()) ::
  {:ok, PS2.API.QueryResult.t()}
  | {:error, HTTPoison.Error.t() | Jason.DecodeError.t() | PS2.API.Error.t()}

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

Specs

get_image(String.t()) :: {:ok, binary()} | {:error, HTTPoison.Error.t()}

Gets the image binary for a .png.

Link to this function

get_image_url(image_path)

View Source

Specs

get_image_url(String.t()) :: String.t()

Gets the image link.

Link to this function

query(query, service_id, httpoison_opts \\ [])

View Source

Specs

query(PS2.API.Query.t(), String.t(), Keyword.t()) ::
  {:ok, PS2.API.QueryResult.t()}
  | {:error, HTTPoison.Error.t() | Jason.DecodeError.t() | PS2.API.Error.t()}

Sends query to the API and returns a list of results if successful. service_id is the Census service_id with which the query will be sent. opts is a keyword list of HTTPoison opts.

Link to this function

query_one(query, service_id, httpoison_opts \\ [])

View Source

Specs

query_one(PS2.API.Query.t(), String.t(), Keyword.t()) ::
  {:ok, PS2.API.QueryResult.t()}
  | {:error, HTTPoison.Error.t() | Jason.DecodeError.t() | PS2.API.Error.t()}

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