csbluegem package

csbluegem.client module

class csbluegem.client.Client(session=None)[source]

Bases: object

A CSBlueGem Client.

async with x:

Returns the Client itself. Used to gracefully close the client on exit.

async with csbluegem.Client() as client:
    ...
async search(skin, /, currency=Currency.USD, type=None, pattern=None, price_min=None, price_max=None, wear_min=None, wear_max=None, sort=SortKey.Date, order=Order.Desc, origin=None, date_min=None, date_max=None, limit=None, offset=None, pattern_data=False, filters=None)[source]

This function is a coroutine.

Searches for an item on CSBlueGem.

Parameters:
  • item (Item) – The item to search for.

  • currency (Currency, optional) – The currency to return, by default USD.

  • type (Optional[ItemType], optional) – The item’s type, None for any. By default None.

  • pattern (Optional[int], optional) – The items pattern. None for any pattern. By default None.

  • price_min (Optional[float], optional) – The minimum price of the sale.

  • price_max (Optional[float], optional) – The maximum price of the sale.

  • wear_min (Optional[float], optional) – The minimum float of a returned item.

  • wear_max (Optional[float], optional) – The maximum float of a returned item.

  • sort (SortKey, optional) – How should the results be sorted, by default Date.

  • order (Order, optional) – How to order the results, by default DESC.

  • origin (Optional[Origin], optional) – Where the sales originated from, None for any. By default None.

  • date_min (Optional[datetime.datetime], optional) – The earliest a sale can be from, None for no minimum, by default None.

  • date_max (Optional[datetime.datetime], optional) – The latest a sale can be from, None for no maximum, by default None.

  • limit (Optional[int], optional) – The maximum number of results to return. None for no limit. By default None.

  • offset (Optional[int], optional) – The offset to start returning results from. None for no offset. By default None.

  • pattern_data (bool, optional) – Whether to include pattern data in the returned results, by default False

  • filters (Filter) – Filters to apply to the search.

Returns:

The returned sales.

Return type:

List[Sale]

Raises:
  • BadArgument – You provided an invalid parameter.

  • InvalidRequest – One of the parameters given was invalid.

  • ServerError – The CSBlueGem server could not process the request.

  • NotFound – The search returned no results.

async pattern_data(item, /, pattern=None, sort=SortKey.Pattern, order=Order.Desc, quantity=False, offset=None, limit=None, filters=None)[source]

This function is a coroutine.

Get pattern data for a skin.

Parameters:
  • item (Item) – The item to get pattern data for.

  • pattern (Optional[int], optional) – The pattern to get data for, None for any. By default None

  • sort (SortKey, optional) – How the results should be sorted, by default pattern.

  • order (Order, optional) – How to order the results, by default descending.

  • quantity (bool, optional) – Whether to return quantities of sales. By default False.

  • offset (Optional[int], optional) – The offset to start returning results from. None for no offset. By default None.

  • limit (Optional[int], optional) – The maximum number of results to return, None for no limit. By default None.

Returns:

The resulting data about the patterns.

Return type:

List[PatternData]

Raises:
  • BadArgument – You provided an invalid parameter.

  • InvalidRequest – One of the parameters given was invalid.

  • ServerError – The CSBlueGem server could not process the request.

  • NotFound – The search returned no results.

async pricecheck(item, pattern, wear)[source]

This function is a coroutine.

Runs a price check for an item.

Parameters:
  • item (Item) – The item to price check.

  • pattern (int) – The pattern of the item.

  • wear (float) – The float of the item

Returns:

The price check value, in USD.

Return type:

int

Raises:
  • BadArgument – You provided an invalid argument.

  • InvalidRequest – One of the parameters given was invalid.

  • ServerError – The CSBlueGem server could not process the request.

  • NotFound – The search returned no results.

async close()[source]

Gracefully close the client.

csbluegem.types module

class csbluegem.types.Screenshots(_inspect, inspect_playside, inspect_backside)[source]

Bases: object

Screenshots for a Sale.

inspect

A url to an inspect link. Always returns a url for an inspect link.

This will be None if no inspect links are available.

For CSFloat based sales, this returns the playside inspect link.

Type:

Optional[str]

inspect_playside

A url to the playside inspect link. Only applicable for CSFloat sales.

Type:

Optional[str]

inspect_backside

A url to the backside inspect link. Only applicable for CSFloat sales.

Type:

Optional[str]

property inspect

Returns an inspect link no matter where the underlying Sale originated.

For CSFloat based Sales, this will return the playside inspect link.

If no screenshots are available, this property will return None.

class csbluegem.types.PatternDataScreenshots(csbluegem_screenshot, aq_oiled)[source]

Bases: object

Screenshots that may be associated with this PatternData.

Only available when using pattern_data().

csbluegem_screenshot

A screenshot provided by CSBlueGem

Type:

str

aq_oiled

A screenshot provided from another source.

Type:

str

class csbluegem.types.PatternDataExtra(similar_playside, similar_backside, csfloat_link, search)[source]

Bases: object

Extra information provided for pattern data.

Only available when using pattern_data().

similar_playside

A URL to an image of an item with a similar playside.

Type:

str

similar_backside

A URL to an image of an item with a similar backside.

Type:

str

The CSFloat database query for this pattern.

Type:

str

search

A URL to a search for this pattern.

Type:

str

class csbluegem.types.PatternData(backside_blue, backside_contour_blue, backside_contour_purple, backside_gold, backside_purple, playside_blue, playside_contour_blue, playside_contour_purple, playside_gold, playside_purple, pattern, quantity, screenshots, extra)[source]

Bases: object

Data for a pattern on CSBlueGem.

backside_blue

The percentage of blue visible on the back side.

Type:

float

backside_contour_blue

The number of individual blue sections visible on the back side.

Type:

int

backside_contour_purple

The number of individual purple sections visible on the back side.

Type:

int

backside_gold

The percentage of gold visible on the back side.

Type:

float

backside_purple

The percentage of purple visible on the back side.

Type:

float

playside_blue

The percentage of blue visible on the back side.

Type:

float

playside_contour_blue

The number of individual blue sections visible on the play side.

Type:

int

playside_contour_purple

The number of individual purple sections visible on the play side.

Type:

int

playside_gold

The percentage of gold visible on the play side.

Type:

float

playside_purple

The percentage of purple visible on the play side.

Type:

float

pattern

The pattern represented by this PatternData.

Type:

Optional[int]

quantity

The number of sales attributed to this PatternData.

Type:

Optional[int]

screenshots

Example screenshots of the pattern associated with this PatternData on in game items.

Type:

Optional[PatternDataScreenshots]

extra

Extra information about this PatternData.

Type:

Optional[PatternDataExtra]

class csbluegem.types.SearchMeta(size, total)[source]

Bases: object

Metadata about the search.

size

The number of items returned.

Type:

int

total

The total number of items available.

Type:

int

class csbluegem.types.Sale(buff_id, csfloat, wear, type, pattern, price, timestamp, steam_inspect_link, origin, pattern_data, screenshots)[source]

Bases: object

Represents a record of sale from CSBlueGem

buff_id

The id of the item on Buff.

Type:

int

csfloat

A link to the item on CSFloat.

Type:

str

wear

The float of the item.

Type:

float

type

The type of the item.

Type:

ItemType

pattern

The pattern of the item.

Type:

int

timestamp

When the sale occurred.

Type:

datetime.datetime

The inspect link for this item.

Type:

str

origin

Where the sale data originated.

Type:

Origin

pattern_data

The pattern data for the item, if available.

Type:

Optional[PatternData]

screenshots

Screenshot data for the item.

Type:

Screenshots

property float

The float of the item.

property date

The date this item was sold.

property epoch

The epoch the item was sold.

property days_since

Returns the number of days since this Sale.

property is_stattrak

Whether the item was stattrak

class csbluegem.types.SearchResponse(meta, sales)[source]

Bases: object

Represents a response to a search query.

meta

Metadata about the query.

Type:

SearchMeta

sales

The sales that were returned.

Type:

List[Sale]

class csbluegem.types.PatternDataResponse(meta, pattern_data)[source]

Bases: object

Represents a response to a pattern data query.

meta

Metadata about the query.

Type:

SearchMeta

data

The pattern datas that were returned.

Type:

List[PatternData]

class csbluegem.types.Origin[source]

Where a Sale originated from.

Buff

Buff.163.com

CSFloat

CSFloat.com

SkinBid

SkinBid.com

BroSkins

BroSkins.com

Skinport

Skinport.com

C5Game

c5game.com

class csbluegem.types.FilterType[source]

What a Filter should filter by.

PlaysideBlue

The amount of blue on the play side of the item.

PlaysidePurple

The amount of purple on the play side of the item.

PlaysideGold

The amount of gold on the play side of the item.

BacksideBlue

The amount of blue on the back side of the item.

BacksidePurple

The amount of purple on the back side of the item.

BacksideGold

The amount of gold on the back side of the item.

class csbluegem.types.Filter(type, min, max)[source]

Bases: object

A filter for searches.

type

What kind of filter.

Type:

FilterType

min

The minimum value for this filter.

Type:

float

max

The maximum value for this filter.

Type:

float

is_valid()[source]

Whether or not this Filter is valid.

Returns:

Filter validity.

Return type:

bool

class csbluegem.types.Order[source]

How results from the API should be ordered.

Asc

Sort in ascending order.

Desc

Sort in descending order.

class csbluegem.types.ItemType[source]

The type of an item.

StatTrak

A StatTrak item.

Normal

A non StatTrak item.

class csbluegem.types.Currency[source]

Available currencies for use in the API.”

USD

United States Dollar

EUR

Euros

JPY
Japanese Yen
GBP
Great British Pound
CNY
Chinese Yuan
AUD
Australian Dollar
CAD
Canadian Dollar
class csbluegem.types.SortKey[source]

How the results of a query should be sorted.

PlaysideBlue

The amount of blue on the play side.

PlaysidePurple

The amount of purple on the play side.

PlaysideGold

The amount of gold on the play side.

BacksideBlue

The amount of blue on the back side.

BacksidePurple

The amount of purple on the back side.

BacksideGold

The amount of gold on the back side.

PlaysideContourBlue

The number of blue regions on the play side.

PlaysideContourPurple

The number of purple regions on the play side.

BacksideContourBlue

The number of blue regions on the back side.

BacksideContourPurple

The number of purple regions on the back side.

PatternData

The pattern of the item.

Float

The float of the item.

Date

The date of the sale.

Price

The price of the sale.

class csbluegem.types.Item[source]

Items that can be queried from the API.

AK47

AK-47

Bayonet

Bayonet Knife

BowieKnife

Bowie Knife

ButterflyKnife

Butterfly Knife

ClassicKnife

Classic Knife

DesertEagle_Heat_Treated

Desert Eagle Heat Treated

FalchionKnife

Falchion Knife

FiveSeveN

Five-SeveN

FiveSeveN_Heat_Treated

Five-SeveN Heat Treated

FlipKnife

Flip Knife

GutKnife

Gut Knife

HuntsmanKnife

Huntsman Knife

HydraGloves

Hydra Gloves

Karambit

Karambit Knife

KukriKnife

Kukri Knife

M9Bayonet

M9 Bayonet Knife

MAC10

MAC-10

NavajaKnife

Navaja Knife

NomadKnife

Nomad Knife

ParacordKnife

Paracord Knife

ShadowDaggers

Shadow Daggers

SkeletonKnife

Skeleton Knife

StilettoKnife

Stiletto Knife

SurvivalKnife

Survival Knife

TalonKnife

Talon Knife

UrsusKnife

Ursus Knife

csbluegem.utils module

csbluegem.utils.utcnow()[source]

Returns an aware UTC datetime representing the current time.

Returns:

The current aware datetime in UTC.

Return type:

datetime.datetime

csbluegem.utils.as_chunks(iterable, n)[source]

Batches an iterable into chunks of up to size n.

Parameters:
Raises:

ValueError – At least one result must be returned per group.

csbluegem.utils.safe_get(dict_, *keys)[source]

Safely get a nested key from a dictionary.

ex.

d = {
    'i': 1,
    'j': {
        'k': '2'
    }
}

safe_get(d, 'i')  # -> 1
safe_get(d, 'j', 'k')  # -> '2'
Parameters:
  • dict (Dict[Any, Any]) – The dictionary to get the key from

  • keys (Any) – The keys to get from the dictionary. Processed in order.

Returns:

The value at the key. None if the key could not be gotten.

Return type:

Optional[Any]

csbluegem.errors module

class csbluegem.errors.BlueGemError[source]

Bases: Exception

class csbluegem.errors.BadArgument[source]

Bases: BlueGemError

class csbluegem.errors.HTTPException(code, message='')[source]

Bases: BlueGemError

class csbluegem.errors.NotFound(code, message='')[source]

Bases: HTTPException

class csbluegem.errors.ServerError(code, message='')[source]

Bases: HTTPException

class csbluegem.errors.InvalidRequest(code, message='')[source]

Bases: HTTPException