{"id":13704102,"url":"https://github.com/OmG3r/steam-trade","last_synced_at":"2025-05-05T09:33:08.984Z","repository":{"id":59156456,"uuid":"130513405","full_name":"OmG3r/steam-trade","owner":"OmG3r","description":"This gem simplifes/allows sending steam trade offers programmatically.","archived":false,"fork":false,"pushed_at":"2023-06-23T18:07:57.000Z","size":877,"stargazers_count":9,"open_issues_count":5,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-31T14:26:50.908Z","etag":null,"topics":["ruby","steam","steam-trading","steambot","trade-offers"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OmG3r.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-21T21:30:04.000Z","updated_at":"2023-01-28T19:26:58.000Z","dependencies_parsed_at":"2023-02-18T15:50:18.340Z","dependency_job_id":null,"html_url":"https://github.com/OmG3r/steam-trade","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmG3r%2Fsteam-trade","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmG3r%2Fsteam-trade/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmG3r%2Fsteam-trade/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OmG3r%2Fsteam-trade/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OmG3r","download_url":"https://codeload.github.com/OmG3r/steam-trade/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224439745,"owners_count":17311517,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ruby","steam","steam-trading","steambot","trade-offers"],"created_at":"2024-08-02T21:01:04.272Z","updated_at":"2024-11-13T11:30:51.300Z","avatar_url":"https://github.com/OmG3r.png","language":"Ruby","funding_links":[],"categories":["Packages"],"sub_categories":["Ruby"],"readme":"z# steam-trade V0.3.3\n\n**PLEASE IF SOMETHING DOES NOT WORK PROPERLY MAKE A GITHUB ISSUE**\n\nThis gem simplifes/allows sending steam trade offers programmatically.\n\nthis gem is primarly for trading cards, tho can be used to CS:GO and other games inventories\n\n# Changelog\n```\n0.3.3:\n- hotfix login without api-key\n0.3.2:\n- added send_trade_allow_request() (mobile confirmation) and confirm_all() (mobile confirmation)\n0.3.1:\n- added cottage() , vote_2018() and sell_items()\n\n0.3.0:\n- hotfix for cookie login\n\n0.2.9:\n- hotfix for cookie login (remember me)\n\n0.2.8:\n- fixed cookie login\n\n0.2.7:\n- added salien_card() to collect steam Salien game Trading Cards\n\n0.2.6:\n- hotfix\n\n0.2.5:\n- added finish_queue() to collect Steam Sale Trading Cards\n- hotfix\n\n0.2.4:\n- hotfix\n\n0.2.3:\n- hotfix\n\n0.2.2:\n- fixed issues with ruby 2.4+\n- added class methods for fa(), normal_get_inventory(), raw_get_inventory, sets_count()\n\n0.2.1:\n- many many bugs fixed\n\n0.2.0:\n- hotfix\n\n0.1.9:\n- Handler.new() now accepts a hash contains login cookies.\n- get_auth_cookies() returns cookies to use for the next login\n\n0.1.8:\n- hotfix\n\n0.1.7:\n- hotfix\n\n0.1.6:\n- hotfix\n\n0.1.5:\n- added mobile_login() which allows you to send and receive steam messages\n- added oauth_login() uses oauth token and steamMachine cookie to login in ( you get those from mobile_login())\n\n0.1.4:\n- added Social commands : send friend request, accept friend request, remove friend, send message, get messages\n- added function to update badges blueprint (useful when there is no gem update)\n\n0.1.3:\n- decreased cooldown between requests from 2 seconds to 1 second.\n- added a 0.6 second wait before attempting to confirm a trade offer (mobile).\n- added a 3 times retry to get an inventory chunk before raising an error.\n- exception handling for sets_count, now no longer raises an error if the target inventory contains trading cards which are not specified in the bluepirnt.\n\n0.1.2:\n- normal_get_inventory() and raw_get_inventory() now uses Mechanize instead of open-uri.\n- Handler.new() and fa() now accepts a time difference parameter to adjust your 2FA codes.\n- sets_count() now writes the txt file faster.\n- Mechanize session associated with the account now has a 2 second cooldown before each request to avoid spamming steam servers and resulting in a ban.\n```\n# Table of content\n\n- [Installation](#installation)\n- [Usage \u0026 Examples](#usage)\n  - [Logging-in](#logging-in)\n    - [Hander.new() (this is how you login)](#handlernew)\n      - [Handler.new() (normal login)](#handlernewusername-passwordshared_secrettime_differenceremember_me)\n      - [Handler.new() (cookies login)](#handlernewcookies_hashshared_secrettime_differenceremember_me)\n    - [get_auth_cookies()](#get_auth_cookies)\n    - [mobile_info()](#mobile_infoidentity_secret)\n  - [Getting someone's inventory](#getting-someones-inventory)\n    - [normal_get_inventory()](#normal_get_inventorysteamidinventoryappid)\n    - [raw_get_inventory()](#raw_get_inventorytargetinventoryappidtrimming)\n    - [set_inventory_cache()](#set_inventory_cache)\n  - [Sending a trade offer](#sending-a-trade-offer)\n    - [send_offer()](#send_offermyarraytheirarraytrade_offer_linkmessage)\n    - [send_trade_allow_request()](#send_trade_allow_requesttradeofferid)\n    - [confirm_all()](#confirm_all)\n  - [Handling Trade Offers](#handling-trade-offers)\n    - [set_api_key()](#set_api_keyapi_key)\n    - [get_trade_offers()](#get_trade_offerstime)\n    - [get_trade_offer()](#get_trade_offertradeofferid)\n    - [accept_trade_offer()](#accept_trade_offertradeofferid)\n    - [decline_trade_offer()](#decline_trade_offertradeofferid)\n    - [cancel_trade_offer()](#cancel_trade_offertradeofferid)\n  - [Counting badges owned](#counting-badges-owned)\n    - [sets_count()](#sets_counttargetnon_marketable)\n    - [update_blueprint()](#update_blueprint)\n  - [2FA codes](#2fa-codes)\n    - [fa()](#fashared_secret-time_difference)\n  - [Social Features](#social-commands)\n    - [mobile_login()](#mobile_loginusernamepasswordshared_secret)\n    - [oauth_login()](#oauth_loginoauth_tokensteammachine)\n    - [send_message()](#send_messagetarget-message)\n    - [poll_messages()](#poll_messages)\n    - [send_friend_request()](#send_friend_requesttarget)\n    - [accept_friend_request()](#accept_friend_requesttarget)\n    - [remove_friend()](#remove_friendtarget)\n  - [More commands](#more-commands)\n\n## Installation\nin your commandline :\n\n`gem install steam-trade`\n\n## Usage\nFirst you need to require the gem:\n```ruby\nrequire 'steam-trade'\n```\n## Logging-in\n#### `Handler.new()`\n##### `Handler.new(username, password,shared_secret,time_difference,remember_me)`\nthen you need to login and optionally set your shared_secret and identity_secret:\n- `shared_secret` is used to generate steam authentication codes so you won't have to write them manually each time you login.\n- `time_difference`is the difference between your time and steam servers, this affects how 2FA codes are generated (**this MUST BE an integer**)\n- `remember_me` is a boolean used to indicate whether you want cookies which expire shortly if set to **false** or stay valid for weeks if set to **true**\n```ruby\nrequire 'steam-trade'\n\naccount = Handler.new('username','password','shared_secret') # share secret is optional\naccount = Handler.new('username','password',50) #works\naccount = Handler.new('username','password','shared_secret',50)\naccount = Handler.new('username','password',50,'shared_secret') # this will not work\n\naccount = Handler.new('username','password','shared_secret',20,true) # works\naccount = Handler.new('username','password','shared_secret',true) #works\naccount = Handler.new('username','password',20,true) #works\naccount = Handler.new('username','password',true) #works\n\naccount = Handler.new('username','password','shared_secret',true,20) # will not work\n##########\naccount = Handler.new('username') #this of course counts as non logged in\n\n```\nkeep in mind you can initialize a Handler without params however the commands you will be able to use will be limited\n```ruby\nrequire 'steam-trade'\n\naccount = Handler.new()\nputs account.fa('v3dWNq2Ncutc7RelwRVXswT8CJX=v3dWNq2Ncutc7WelwRVXswT8CJk=') =\u003e random code\n\n```\n\n##### `Handler.new(cookies_hash,shared_secret,time_difference,remember_me)`\n- `cookies_hash` is hash containing `steamLogin`, `steamLoginSecure` and `steamMachineAuth` cookies.\nthis can be used with `get_auth_cookies()` for faster login.\n- `shared_secret` is used to generate steam authentication codes so you won't have to write them manually each time you login.\n- `time_difference`is the difference between your time and steam servers, this affects how 2FA codes are generated (**this MUST BE an integer**)\n- `remember_me` is a boolean used to indicate whether you want cookies which expire shortly if set to **false** or stay valid for weeks if set to **true**\n\n\n```ruby\nrequire 'steam-trade'\naccount = Handler.new(JSON.parse(File.read('./creds.json'))) # creds.json is created by get_auth_cookies()\n\naccount = Handler.new(JSON.parse(File.read('./creds.json')), 'shared_secret', 50)\n```\n\n#### `get_auth_cookies()`\n- returns the current logged in account cookies to use in the future.\n```ruby\nrequire 'steam-trade'\naccount = Handler.new('username','password','shared_secret',true)\ncookies = h.get_auth_cookies\n\nFile.open('creds.json', 'w') {|f| f.puts cookies.to_json}\n```\nnext time :\n```ruby\nrequire 'steam-trade'\naccount = Handler.new(JSON.parse(File.read('./creds.json')))\n```\n\n#### `mobile_info(identity_secret)`\n- `identity_secret` is your account's identity secret (try using google if you don't know what this is).\n- `identity_secret` is used to automatically confirm trade offers.\n```ruby\nrequire 'steam-trade'\n\naccount = Handler.new('username','password','shared_secret')\naccount.mobile_info('identity_secret')\n```\n\n## Getting someone's inventory\nyou might want to read this [guide](https://dev.doctormckay.com/topic/332-identifying-steam-items/)\n#### `normal_get_inventory('steamid','inventoryappid')`\n- `steamid` is the target's steamID, or profileID, or trade link\n- `inventoryappid` is the inventory type you want to load, `ex : normal inventory(the one which holds trading cards), it's is 753`\n- if you call `normal_get_inventory()` with no params, it will be default use the current logged-in account `steamid`, `inventoryappid = 753`\n\n```ruby\nrequire 'steam-trade'\ninventory = Handler.normal_get_inventory(\"nomg3r\")\n\n\nlogged = Handler.new('username','password','shared_secret')\nlogged.mobile_info('identity_secret')\n# while logged in\nmy_inventory = logged.normal_get_inventory() #will get your normal inventory(753) if you are logged in else raise an exception\nmy_inventory = logged.normal_get_inventory('730') # will get your CS:GO inventory if you are logged in else raise an exeception\n\n\n#whatever can be done while **not** logged in, can be of course used while logged in\n#while not logged in\nnonlogged = Handler.new()\nmy_inventory = nonlogged.normal_get_inventory() #will raise an exception\nmy_inventory = nonlogged.normal_get_inventory('730') #will raise an exception\n\n#whenever\npartner_inventory = nonlogged.normal_get_inventory('76561198044170935') #using steamid\npartner_inventory = nonlogged.normal_get_inventory('https://steamcommunity.com/tradeoffer/new/?partner=410155236\u0026token=H-yK-GFt') #using trade link\npartner_inventory = nonlogged.normal_get_inventory('CardExchange') #using profile id\n\n\npartner_inventory = nonlogged.normal_get_inventory('76561198044170935',730) #will get that steamid CS:GO inventory\npartner_inventory = nonlogged.normal_get_inventory('https://steamcommunity.com/tradeoffer/new/?partner=410155236\u0026token=H-yK-GFt', '730') #will get that trade link owner's CS:GO inventory\npartner_inventory = nonlogged.normal_get_inventory('CardExchange',730) # will get CardExchange's CS:GO inventory\n\n\n```\nthe returned items from `normal_get_inventory()` are in the form of an array example : `[item1,item2,item3...itemN]`.\n\neach item is a hash which contains information about the item in the form of `{\"appid\"=\u003e'xxx',\"contextid\"=\u003e'xxx',\"assetid\" =\u003e 'xxx',\"classid\"=\u003e 'xxx',......\"name\"=\u003e 'xxxx',\"market_fee_app\" =\u003e 'xxx',....}`.\n\n`market_fee_app` key gives you the appid of the game's app (for trading cards), for other items technically `inventoryappid` is the games appid.\n\n`name` key gives you the item name.\n#### `raw_get_inventory(target,inventoryappid,trimming)`\n**IMPORTANT**: this command efficiency is better than `normal_get_inventory`, therefore i **recommend**  using this one.\n- `target` is a steamID/profileID/trade link\n- `inventoryappid` is the inventory type you want to load, `ex : normal inventory(the one which holds trading cards), it's is 753`\n- `trimming`, defaults to `true` this will remove images link and steam-server-side related informations from the descriptions hash, drastically reducing the size of data received.\n\nThis command will return a hash nearly identitical to the one received from steam the hash will have 2 keys `assets` and `descriptions`:\n- `assets` has an array as value, identical to steam's [(example)](https://steamcommunity.com/inventory/76561198044170935/753/6?start_assetid=0\u0026count=100)\n- `descriptions` has an array as a value identical to steam's [(example)](https://steamcommunity.com/inventory/76561198044170935/753/6?start_assetid=0\u0026count=100)\n\n```ruby\nrequire 'steam-trade'\ninv = Handler.raw_get_inventory(\"nomg3r\")\n\n\nlogged = Handler.new('username','password','shared_secret')\ninv = logged.raw_get_inventory() #works\ninv = logged.raw_get_inventory(false) # returns non trimmed\ninv = logged.raw_get_inventory(440) #works\ninv = logged.raw_get_inventory(76561198044170935,false) #works\ninv = logged.raw_get_inventory(76561198044170935,440) # works\n\nprint inv['assets'] #will print all the assets\nprint inv['descriptions'] #will print all the descriptions\n\n### how to accurately use this\n\nclass_instance = {}\n## map all the items\ninv['descriptions'].each { |desc|\n  identifier = desc['classid'] + '_' + desc['instanceid']\n  class_instance[identifier] = desc\n}\n\n## identify your items\n\ninv['assets'].each { |asset|\n  identifier = asset['classid'] + '_' + asset['instanceid']\n  puts class_instance[identifier] this will output the item's description\n}\n\n```\n\n#### `set_inventory_cache()`\n`set_inventory_cache()` is:\n\n- a switch to locally save each inventory you get to a local file.\n- disabled by default, you need to initiate it by calling the command\n- accepts a parameter `timer` which defaults to `timer = 120`, this parameter is the difference between the save file was created and the moment it was checked (upong trying to retrieve the inventory).\n\n- this switch is useful if you are getting a \"static\" inventory or testing your code.\n```ruby\nrequire 'steam-trade'\n\nlogged = Handler.new('username','password','shared_secret')\nlogged.mobile_info('identity_secret')\nlogged.set_inventory_cache(150)\n\n\npartner_inventory = loggedlogged.normal_get_inventory('CardExchange') #this will save CardExchange's inventory to a local file and return the inventory\n\npartner_inventory = loggedlogged.normal_get_inventory('CardExchange') # this will load the locally saved file\n\n\n```\n\n**IMPORTANT**: `normal_get_inventory()` will load the whole target inventory, for each **5k** of items, you are adding **~40MB** to your memory and of course will affect performance of the code and the computer\n## Sending a trade offer\n#### `send_offer(myarray,theirarray,trade_offer_link,message)`\n**MUST be logged in to use this command**\nthen you can send your offer\n- `myarray` is an array which contains hashes of selected items to send in the offer. (currently you must get this on your own)\n- `Theirarray` is an array which contains hashes of selected items to receive in the offer. (currently you must get this on your own)\n- `trade_offer_link` can be the trade link of you partner `ex: https://steamcommunity.com/tradeoffer/new/?partner=410155236\u0026token=H-yK-GFt`\n- `trade_offer_link` can be a steamID, however using a steamID requires you and your partner to be friends on steam\n- `trade_offer_link` can  be a profileID, however using a profileID requires you and your partner to be friends on steam\n- `message` is the comment you want to include in the trade offer\n\n- `myarray`, `theirarray`, `trade_offer_link` are required, `message` is optional\n- **returns a hash which contains informations about the trade**\n- **identity_secret** is required for this function to work\n```ruby\nrequire 'steam-trade'\n\naccount = Handler.new('username','password','shared_secret')\naccount.mobile_info('identity_secret')\n\nme = account.normal_get_inventory()\nhis = account.normal_get_inventory(\"nomg3r\")\n\nmyarray = [me[5] , me[20] , me[60]].compact!\ntheirarray = [his[1], his[20], his[30]].compact!\n\n# if you are friends\nresp = account.send_offer(myarray,theirarray,\"nomg3r\",message)\n#or (as friends)\naccount.send_offer(myarray,theirarray,'76561198370420964',message)\n\n# whenever\naccount.send_offer(myarray,theirarray,\"https://steamcommunity.com/tradeoffer/new/?partner=410155236\u0026token=H-yK-GFt\",message)\n\n\n```\n\n#### `send_trade_allow_request(tradeofferid)`\n- `tradeofferid` is the ID of the offer you want to confirm (mobile confirmation)\n- **identity_secret** is required for this function to work\n```ruby\nrequire 'steam-trade'\n\naccount = Handler.new('username','password','shared_secret')\naccount.mobile_info('identity_secret')\n\nme = account.normal_get_inventory()\nhis = account.normal_get_inventory(\"nomg3r\")\n\nmyarray = [me[5] , me[20] , me[60]].compact!\ntheirarray = [his[1], his[20], his[30]].compact!\n\nresp = account.send_offer(myarray,theirarray,\"nomg3r\",message)\n\naccount.send_trade_allow_request(resp['tradeofferid'])\n\n```\n\n#### `confirm_all()`\n- confirms all trades which are waiting for mobile confirmation\n- **identity_secret** is required for this function to work\n\n```ruby\nrequire 'steam-trade'\n\naccount = Handler.new('username','password','shared_secret')\naccount.mobile_info('identity_secret')\n\naccount.confirm_all\n```\n## Handling Trade Offers\nyou might want to read [Steam Trading API](https://developer.valvesoftware.com/wiki/Steam_Web_API/IEconService)\n\n**ALL OF THE COMMANDS BELOW REQUIRE AN API_KEY**\n\n#### `set_api_key(API_KEY)`\n**NOTE**:If you are using a **logged in** Handler there is no need to set the API_KEY.\n- `API_KEY` is your apikey, you can get that from [here](https://steamcommunity.com/dev/apikey).\n```ruby\nrequire 'steam-trade'\nacc = Handler.new()\ntrade_offers = acc.get_trade_offers() # will raise an exception\nacc.set_api_key('mykey')\ntrade_offers = acc.get_trade_offers() # after setting an API_KEY this will succeed\n```\n#### `get_trade_offers(time)`\n- `time` is the moment from which you want to get updates (explained in the example)\nthis will return a hash with `trade_offers_sent`, `trade_offers_received`, `descriptions` as keys.\n`descriptions` includes the descriptions of all items returned from `trade_offers_sent` or `trade_offers_received`\n\n```ruby\nrequire 'steam-trade'\nlogged = Handler.new('username','password','shared_secret')\nlogged.mobile_info('identity_secret')\n\ntime = '' # this is the initial check for offers so we want them all\npolling = Thread.new(logged) { |logged|\n  loop do\n    offers = logged.get_trade_offers(time)\n    time = Time.new.to_i # we save the time of the last check\n    next if offers['trade_offers_received'] == nil # do nothing, if there is no trades\n    puts offers['trade_offers_received'] # puts the trades\n    sleep(15) # make sure not to spam steam's server or they will block list your IP for a period of time therefore you can't make requests\n  end\n}\n```\n#### `get_trade_offer(tradeofferid)`\ngets more information about a specific trade offer\n- `tradeofferid` is the id of the offer you want to confirm (you can get the id using [this](#get_trade_offerstime) to get the offerID\n\nhave no example how to actually use this cause `get_trade_offers(time)` is probably better\n\n#### `accept_trade_offer(tradeofferid)`\n- `tradeofferid` is the id of the offer you want to confirm (you can get the id using [this](#get_trade_offerstime) to get the offerID\n```ruby\nrequire 'steam-trade'\nlogged = Handler.new('username','password','shared_secret')\nlogged.mobile_info('identity_secret')\n\ntime = '' # this is the initial check for offers so we want them all\npolling = Thread.new(logged) { |logged|\n  loop do\n    offers = logged.get_trade_offers(time)\n    time = Time.new.to_i # we save the time of the last check\n    next if offers['trade_offers_received'] == nil # do nothing, if there is no trades\n    offers['trade_offers_received'].each { |trade|\n      if trade['accountid_other'].to_i == 83905207 ## this will accept all trade received from 83905207 (Steam32 ID)\n        logged.accept_trade_offer(trade['tradeofferid']) # to accept the trade\n      end\n    }\n    sleep(15) # make sure not to spam steam's server or they will block list your IP for a period of time therefore you can't make requests\n  end\n}\n```\n#### `decline_trade_offer(tradeofferid)`\nthis declines a trade offer you **RECEIVED**\n- `tradeofferid` is the id of the offer you want to confirm (you can get the id using [this](#get_trade_offerstime) to get the offerID\n\n```ruby\nrequire 'steam-trade'\nlogged = Handler.new('username','password','shared_secret')\nlogged.mobile_info('identity_secret')\n\ntime = '' # this is the initial check for offers so we want them all\npolling = Thread.new(logged) { |logged|\n  loop do\n    offers = logged.get_trade_offers(time)\n    time = Time.new.to_i # we save the time of the last check\n    next if offers['trade_offers_received'] == nil # do nothing, if there is no trades\n    offers['trade_offers_received'].each { |trade| # we need to check received offers to use 'decline'\n      if trade['accountid_other'].to_i != 83905207 ## notice the '!='\n        logged.decline_trade_offer(trade['tradeofferid']) # decline the trade\n      end\n    }\n    sleep(15) # make sure not to spam steam's server or they will block list your IP for a period of time therefore you can't make requests\n  end\n}\n```\n#### `cancel_trade_offer(tradeofferid)`\nthis cancels a trade offer you **SENT**\n- `tradeofferid` is the id of the offer you want to confirm (you can get the id using [this](#get_trade_offerstime) to get the offerID\n```ruby\nrequire 'steam-trade'\nlogged = Handler.new('username','password','shared_secret')\nlogged.mobile_info('identity_secret')\n\ntime = '' # this is the initial check for offers so we want them all\npolling = Thread.new(logged) { |logged|\n  loop do\n    offers = logged.get_trade_offers(time)\n    time = Time.new.to_i # we save the time of the last check\n    next if offers['trade_offers_sent'] == nil # do nothing, if there is no trades\n    offers['trade_offers_sent'].each { |trade| # we need to check sentoffers to use 'cancel'\n      if trade['accountid_other'].to_i != 83905207 ## notice the '!='\n        logged.cancel_trade_offer(trade['tradeofferid']) # cancel the trade\n      end\n    }\n    sleep(15) # make sure not to spam steam's server or they will block list your IP for a period of time therefore you can't make requests\n  end\n}\n```\n## Counting badges owned\n#### `sets_count(target,non_marketable)`\n**this command does not count foil badges (only normal trading cards)**\n- `target` can be a steamID, a profileID or a trade link\n- `non_marketable` this is a switch to count **non**-marketable trading cards(defaults to **true** if not specified)\n- a .txt will be created from this command to read the badges\n- this returns a hash  `{'sets' =\u003e appsets, 'appxsets' =\u003e setsowned, 'totalsets' =\u003e numberofsets, 'totalcards' =\u003e total_non_foil, 'marketable' =\u003e true}`\n  - `'sets'` is a hash with game appids as keys and each card and number of copies owned of each card `{'appid1' =\u003e {'card1' =\u003e 5,'card2' =\u003e 3, ... 'cardN' =\u003e Z},{'appid1' =\u003e {'card1' =\u003e 0,'card2' =\u003e 2, ... 'cardN' =\u003e K} }`\n  - `'appxsets'` is a hash containing the number of sets available of each set `{'appid1' =\u003e 5,'appid2' =\u003e 20,...'appidN' =\u003e Z}`\n  - `'totalsets'` is an integer equals to the number of sets owned\n  - `'totalcards'` is an integer equals to the number of non-foil cards account for\n```ruby\nrequire 'steam-trade'\ndata = Handler.sets_count(\"CardExchange\")\n\n\nlogged = Handler.new('username','password','shared_secret')\nlogged.mobile_info('identity_secret')\n#with login\nlogged = account.sets_count()\nlogged = account.sets_count(false)\nhash = account.sets_count('CardExchange',false)\nhash = account.sets_count(76561198370420964)\nhash = account.sets_count('https://steamcommunity.com/tradeoffer/new/?partner=410155236\u0026token=H-yK-GFt',false)\n\n\n#without login\nnonlogged = Handler.new()\nlogged = account.sets_count() #raise exception\nlogged = account.sets_count(false) # raise exception\nhash = account.sets_count('CardExchange')\nhash = account.sets_count(76561198370420964)\nhash = account.sets_count('https://steamcommunity.com/tradeoffer/new/?partner=410155236\u0026token=H-yK-GFt',false)\n\n```\n\n#### `update_blueprint()`\n- updates your locally saved badges blueprint\n```ruby\nrequire 'steam-trade'\n\nhandler = Handler.new\n\nhandler.update_blueprint()\n```\n## 2FA codes\n#### `fa(shared_secret, time_difference)`\n- `shared_secret` is the account's shared secret (if you don't know what is this try googling 'steam shared_secret'), defaults to the logged in account's steamid if logged in.\n- `time_difference` is the difference between your pc's time and steam's time (**this MUST BE an integer**)\n**NOTE**: using this command with a new shared_secret will not change/set the current saved shared_secret for the account\n```ruby\nrequire 'steam-trade'\nputs Hander.fa('random_shared_secret')\n\n\nlogged = Handler.new('username','password','inital_shared_secret')\nputs logged.fa() #=\u003e random code for your account\nputs logged.fa('new_shared_secret') # =\u003e this will give you a random code for another account, AND will not edit your initial_shared_secret\n\n####\nlogged_without_shared_secret = Handler.new('username','password') # this is possible of course\nputs logged_without_shared_secret.fa() # this will not work\nputs logged_without_shared_secret.fa('shared_secret') ## will give a random code\n###\nnonlogged = Handler.new()\nputs nonlogged.fa() # will not work\nputs logged.fa() # will give a random code\n\n```\n## Social Commands\n#### `mobile_login('username','password','shared_secret')`\n- this command will be called automatically if you attempt to use `send_message()` or `poll_messages()` without authentication\n- calling this explicitly allows you to painlessly retrieve the OAuth token and `SteamMachine#{steamid}` cookie to use in `oauth_login()`\n- this function returns a hash with `oauth_token` and `machine` as keys\n```ruby\nrequire 'steam-trade'\n\nh = Handler.new('user','pass','secret')\ndata = h.mobile_login() #this works are you have setted username and password\nputs data ## will output with oauth token and steamMachine cookie\n\n###################\nh = Handler.new()\ndata = h.mobile_login() # will raise an error cause there is no username or password\n\n##########\n\nh = Handler.new()\ndata = h.mobile_login('user','pass','secret') ## will work, you are not logged in ( talking about community) here you can't use most of the commands (send_offer() etc) and those parameters you passed will not be setted as the Handler's\n\n######\nh = Handler.new('user1','pass1','secret1')\ndata = mobile_login('user2','pass2','secret2') # this works but trading commands etc will be called using user1, and chat commands will be called using user2\n```\n#### `oauth_login(oauth_token,SteamMachine)`\n- `oauth_token` and `SteamMachine` can be retrieved from `mobile_login()`\n```ruby\nrequire 'steam-trade'\nh = Handler.new()\nh.oauth_login('oauth_token','SteamMachine')\n```\n#### `send_message(target, message)`\nsends a message to the target\n- `target` can be a steamID64, tradelink, or profileID\n- `message` the message to send\n```ruby\nrequire 'steam-trade'\n\nh = Handler.new('username', 'password')\nh.send_message('nomg3r', \"Hello, Friend\")\n```\n\n#### `poll_messages()`\ngives you the messages you receieved (after mobile login is initiated (after you call send_message() or poll_messages()  ) )\n\n```ruby\nrequire 'steam-trade'\n\nh = Handler.new('username', 'password')\nprint h.poll_messages() # will not return messages so you call at again ( only the first time in the whole program )\nputs \"\"\nputs \"------\"\nsleep(10) #send a message to the logged in account\nprint h.poll_messages() # actually have messages ( if you received some in the time between the first and the second request )\n```\n**ALL OF THE COMMANDS BELOW REQUIRES LOGIN**\n#### `send_friend_request(target)`\nsends a friend request to the target\n- `target` can be a steamID64, tradelink, or profileID\n\n```ruby\nrequire 'steam-trade'\n\nh = Handler.new('username', 'password')\nh.send_friend_request('nomg3r')\n```\n\n#### `accept_friend_request(target)`\naccepts a friend request from the target\n- `target` can be a steamID64, tradelink, or profileID\n\n```ruby\nrequire 'steam-trade'\n\nh = Handler.new('username', 'password')\nh.accept_friend_request('nomg3r')\n```\n\n### `remove_friend(target)`\nremoves a friend\n- `target` can be a steamID64, tradelink, or profileID\n\n```ruby\nrequire 'steam-trade'\n\nh = Handler.new('username', 'password')\nh.remove_friend('nomg3r')\n```\n\n## More commands\nyou can find more non-vital commands in the [wiki](https://github.com/OmG3r/steam-trade/wiki)\n## License\n\nThe gem is available as open source under the terms of the [GNU GPLV3](https://github.com/OmG3r/steam-trade/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOmG3r%2Fsteam-trade","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FOmG3r%2Fsteam-trade","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOmG3r%2Fsteam-trade/lists"}