Package: cod-api
cod-python-apiCall Of Duty API Libraryforpythonwith the implementation of both public and private API used by activision on
callofduty.comDevsTodo LodoEngineer15ContributorsWerseterPartnered CodeNode-CallOfDutyby:LierrmmDocumentationThis package can be used directly as a python file or as a python library.InstallationInstall cod-api library usingpip:pipinstall-Ucod-apiUsageInitiationImport module with its classes:fromcod_apiimportAPIapi=API()Login with your sso token:api.login('Your sso token')Your sso token can be found by longing in atcallofduty, opening dev tools (ctr+shift+I), going to Applications >
Storage > Cookies >https://callofduty.com, filter to search ‘ACT_SSO_COOKIE’ and copy the value.Game/Other sub classesFollowing importation and initiation of the classAPI, its associated subclasses can be called byAPI.subClassName.Below are the available sub classes:sub classcategoryColdWargameModernWarfaregameModernWarfare2gameVanguardgameWarzonegameWarzone2gameMeotherShopotherMiscotherFor a detailed description,__doc__(docstring) of each sub class can be called as shown below:ColdWar:fromcod_apiimportAPIapi=API()# print out the docstringprint(api.ColdWar.__doc__)ModernWarfare:fromcod_apiimportAPIapi=API()# print out the docstringprint(api.ModernWarfare.__doc__)ModernWarfare2:fromcod_apiimportAPIapi=API()# print out the docstringprint(api.ModernWarfare2.__doc__)Vanguard:fromcod_apiimportAPIapi=API()# print out the docstringprint(api.Vanguard.__doc__)Warzone:fromcod_apiimportAPIapi=API()# print out the docstringprint(api.Warzone.__doc__)Warzone2:fromcod_apiimportAPIapi=API()# print out the docstringprint(api.Warzone2.__doc__)Me:fromcod_apiimportAPIapi=API()# print out the docstringprint(api.Me.__doc__)Shop:fromcod_apiimportAPIapi=API()# print out the docstringprint(api.Shop.__doc__)Misc:fromcod_apiimportAPIapi=API()# print out the docstringprint(api.Misc.__doc__)Full Profile HistoryAny sub class ofAPIthat is of game category, has methods to check a player’s combat history.
Note that before calling any sub class methods ofAPIyou must belogged in.
Main method isfullData()andfullDataAsync()which is available forColdWar,ModernWarfare,ModernWarfare2,Vanguard,WarzoneandWarzone2classes.Here’s an example for retrievingWarzonefull profile history of a player whose gamer tag isUsername#1234on platformBattlenet:fromcod_apiimportAPI,platformsimportasyncio## sync# initiating the API classapi=API()# login in with sso tokenapi.login('your_sso_token')# retrieving combat historyprofile=api.Warzone.fullData(platforms.Battlenet,"Username#1234")# returns data of type dict# printing results to consoleprint(profile)## async# in an async functionasyncdefexample():# login in with sso tokenawaitapi.loginAsync('your_sso_token')# retrieving combat historyprofile=awaitapi.Warzone.fullDataAsync(platforms.Battlenet,"Username#1234")# returns data of type dict# printing results to consoleprint(profile)# CALL THE example FUNCTION IN AN ASYNC ENVIRONMENTCombat HistoryMain methods arecombatHistory()andcombatHistoryWithDate()for sync environments andcombatHistoryAsync()andcombatHistoryWithDateAsync()for async environments which are available for allColdWar,ModernWarfare,ModernWarfare2,Vanguard,WarzoneandWarzone2classes.ThecombatHistory()andcombatHistoryAsync()takes 2 input parameters which areplatformandgamertagof
typecod_api.platformsand string respectively.Here’s an example for retrievingWarzonecombat history of a player whose gamer tag isUsername#1234on platformBattlenet:fromcod_apiimportAPI,platforms# initiating the API classapi=API()## sync# login in with sso tokenapi.login('your_sso_token')# retrieving combat historyhist=api.Warzone.combatHistory(platforms.Battlenet,"Username#1234")# returns data of type dict# printing results to consoleprint(hist)## async# in an async functionasyncdefexample():# login in with sso tokenawaitapi.loginAsync('your_sso_token')# retrieving combat historyhist=awaitapi.Warzone.combatHistoryAsync(platforms.Battlenet,"Username#1234")# returns data of type dict# printing results to consoleprint(hist)# CALL THE example FUNCTION IN AN ASYNC ENVIRONMENTThecombatHistoryWithDate()andcombatHistoryWithDateAsync()takes 4 input parameters which areplatform,gamertag,startandendof typecod_api.platforms, string, int and int respectively.startandendparameters are utc timestamps in microseconds.Here’s an example for retrievingModernWarfarecombat history of a player whose gamer tag isUsername#1234567on
platformActivisionwith in the timestamps1657919309(Friday, 15 July 2022 21:08:29) and1657949309(Saturday, 16 July 2022 05:28:29):fromcod_apiimportAPI,platforms# initiating the API classapi=API()## sync# login in with sso tokenapi.login('your_sso_token')# retrieving combat historyhist=api.Warzone.combatHistoryWithDate(platforms.Activision,"Username#1234567",1657919309,1657949309)# returns data of type dict# printing results to consoleprint(hist)## async# in an async functionasyncdefexample():# login in with sso tokenawaitapi.loginAsync('your_sso_token')# retrieving combat historyhist=awaitapi.Warzone.combatHistoryWithDateAsync(platforms.Battlenet,"Username#1234",1657919309,1657949309)# returns data of type dict# printing results to consoleprint(hist)# CALL THE example FUNCTION IN AN ASYNC ENVIRONMENTAdditionally the methodsbreakdown()andbreakdownWithDate()for sync environments andbreakdownAsync()andbreakdownWithDateAsync()for async environments, can be used to retrieve combat history without details, where only
the platform played on, game title, UTC timestamp, type ID, match ID and map ID is returned for every match. These
methods are available for allColdWar,ModernWarfare,ModernWarfare2,Vanguard,WarzoneandWarzone2classes.Thebreakdown()andbreakdownAsync()`takes 2 input parameters which areplatformandgamertagof typecod_api.platformsand string respectively.Here’s an example for retrievingWarzonecombat history breakdown of a player whose gamer tag isUsername#1234on platformBattlenet:fromcod_apiimportAPI,platforms# initiating the API classapi=API()## sync# login in with sso tokenapi.login('your_sso_token')# retrieving combat history breakdownhist_b=api.Warzone.breakdown(platforms.Battlenet,"Username#1234")# returns data of type dict# printing results to consoleprint(hist_b)## async# in an async functionasyncdefexample():# login in with sso tokenawaitapi.loginAsync('your_sso_token')# retrieving combat history breakdownhist_b=awaitapi.Warzone.breakdownAsync(platforms.Battlenet,"Username#1234")# returns data of type dict# printing results to consoleprint(hist_b)# CALL THE example FUNCTION IN AN ASYNC ENVIRONMENTThebreakdownWithDate()andbreakdownWithDateAsync()takes 4 input parameters which areplatform,gamertag,startandendof typecod_api.platforms, string, int and int respectively.startandendparameters are utc timestamps in microseconds.Here’s an example for retrievingModernWarfarecombat history breakdown of a player whose gamer tag isUsername#1234567on platformActivisionwith in the timestamps1657919309(Friday, 15 July 2022 21:08:29)
and1657949309(Saturday, 16 July 2022 05:28:29):fromcod_apiimportAPI,platforms# initiating the API classapi=API()## sync# login in with sso tokenapi.login('your_sso_token')# retrieving combat history breakdownhist_b=api.Warzone.breakdownWithDate(platforms.Activision,"Username#1234567",1657919309,1657949309)# returns data of type dict# printing results to consoleprint(hist_b)## async# in an async functionasyncdefexample():# login in with sso tokenawaitapi.loginAsync('your_sso_token')# retrieving combat history breakdownhist_b=awaitapi.Warzone.breakdownWithDateAsync(platforms.Activision,"Username#1234567",1657919309,1657949309)# returns data of type dict# printing results to consoleprint(hist_b)# CALL THE example FUNCTION IN AN ASYNC ENVIRONMENTMatch DetailsTo retrieve details of a specific match, the methodmatchInfo()for sync environments andmatchInfoAsync()for
async environments can be used. These methods are available for allColdWar,ModernWarfare,ModernWarfare2,Vanguard,WarzoneandWarzone2classes. Details returned by this method contains additional data than that
of details returned by thecombat historymethods for a single match.ThematchInfo()andmatchInfoAsync()takes 2 input parameters which areplatformandmatchIdof typecod_api.platformsand integer respectively.Optionally the match ID can be retrieved during your gameplay where it will be visible on bottom left cornerHere’s an example for retrievingWarzonematch details of a match where its id is9484583876389482453on platformBattlenet:fromcod_apiimportAPI,platforms# initiating the API classapi=API()## sync# login in with sso tokenapi.login('your_sso_token')# retrieving match detailsdetails=api.Warzone.matchInfo(platforms.Battlenet,9484583876389482453)# returns data of type dict# printing results to consoleprint(details)## async# in an async functionasyncdefexample():# login in with sso tokenawaitapi.loginAsync('your_sso_token')# retrieving match detailsdetails=awaitapi.Warzone.matchInfoAsync(platforms.Battlenet,9484583876389482453)# returns data of type dict# printing results to consoleprint(details)# CALL THE example FUNCTION IN AN ASYNC ENVIRONMENTSeason LootUsing theseasonLoot()for sync environments andseasonLootAsync()for async environments, player’s obtained
season loot can be retrieved for a specific game and this method is available forColdWar,ModernWarfare,ModernWarfare2andVanguardclasses.TheseasonLoot()andseasonLootAsync()takes 2 input parameters which areplatformandmatchIdof typecod_api.platformsand integer respectively.Here’s an example for retrievingColdWarseason loot obtained by a player whose gamer tag isUsername#1234on
platformBattlenet:fromcod_apiimportAPI,platforms# initiating the API classapi=API()## sync# login in with sso tokenapi.login('your_sso_token')# retrieving season lootloot=api.ColdWar.seasonLoot(platforms.Battlenet,"Username#1234")# returns data of type dict)# printing results to consoleprint(loot)## async# in an async functionasyncdefexample():# login in with sso tokenawaitapi.loginAsync('your_sso_token')# retrieving season lootloot=awaitapi.ColdWar.seasonLootAsync(platforms.Battlenet,"Username#1234")# returns data of type dict# printing results to consoleprint(loot)# CALL THE example FUNCTION IN AN ASYNC ENVIRONMENTMap ListUsing themapList()for sync environments andmapListAsync()for async environments, all the maps and its
available modes can be retrieved for a specific game. These methods are available forColdWar,ModernWarfare,ModernWarfare2andVanguardclasses.ThemapList()andmapListAsync()takes 1 input parameters which isplatformof typecod_api.platforms.Here’s an example for retrievingVanguardmap list and available modes respectively on platform PlayStation
(PSN):fromcod_apiimportAPI,platforms# initiating the API classapi=API()## sync# login in with sso tokenapi.login('your_sso_token')# retrieving maps and respective modes availablemaps=api.Vanguard.mapList(platforms.PSN)# returns data of type dict# printing results to consoleprint(maps)## async# in an async functionasyncdefexample():# login in with sso tokenawaitapi.loginAsync('your_sso_token')# retrieving season lootmaps=awaitapi.Vanguard.mapListAsync(platforms.PSN)# returns data of type dict# printing results to consoleprint(maps)# CALL THE example FUNCTION IN AN ASYNC ENVIRONMENTplatformsplatformsis an enum class available incod_apiwhich is used to specify the platform in certain method calls.Availableplatformsare as follows:PlatformRemarksplatforms.AllAll (no usage till further updates)platforms.ActivisionActivisionplatforms.BattlenetBattlenetplatforms.PSNPlayStationplatforms.SteamSteam (no usage till further updates)platforms.UnoUno (activision unique id)platforms.XBOXXboxplatformscan be imported and used as follows:fromcod_apiimportplatformsplatforms.All# All (no usage till further updates)platforms.Activision# Activisionplatforms.Battlenet# Battlenetplatforms.PSN# PlayStationplatforms.Steam# Steam (no usage till further updates)platforms.Uno# Uno (activision unique id)platforms.XBOX# XboxUser InfoUsing theinfo()method in sub classMeofAPIuser information can be retrieved of the sso-token logged in
withfromcod_apiimportAPI# initiating the API classapi=API()# login in with sso tokenapi.login('your_sso_token')# retrieving user infouserInfo=api.Me.info()# returns data of type dict# printing results to consoleprint(userInfo)User Friend FeedUsing the methods,friendFeed()for sync environments andfriendFeedAsync()for async environments, in sub classMeofAPI, user’s friend feed can be retrieved of the sso-token logged in withfromcod_apiimportAPI# initiating the API classapi=API()## sync# login in with sso tokenapi.login('your_sso_token')# retrieving user friend feedfriendFeed=api.Me.friendFeed()# returns data of type dict# printing results to consoleprint(friendFeed)## async# in an async functionasyncdefexample():# login in with sso tokenawaitapi.loginAsync('your_sso_token')# retrieving user friend feedfriendFeed=awaitapi.Me.friendFeedAsync()# returns data of type dict# printing results to consoleprint(friendFeed)# CALL THE example FUNCTION IN AN ASYNC ENVIRONMENTUser Event FeedUsing the methodseventFeed()for sync environments andeventFeedAsync()for async environments, in sub classMeofAPIuser’s event feed can be retrieved of the sso-token logged in withfromcod_apiimportAPI# initiating the API classapi=API()## sync# login in with sso tokenapi.login('your_sso_token')# retrieving user event feedeventFeed=api.Me.eventFeed()# returns data of type dict# printing results to consoleprint(eventFeed)## async# in an async functionasyncdefexample():# login in with sso tokenawaitapi.loginAsync('your_sso_token')# retrieving user event feedeventFeed=awaitapi.Me.eventFeedAsync()# returns data of type dict# printing results to consoleprint(eventFeed)# CALL THE example FUNCTION IN AN ASYNC ENVIRONMENTUser IdentitiesUsing the methodsloggedInIdentities()for sync environments andloggedInIdentitiesAsync()for async
environments, in sub classMeofAPIuser’s identities can be retrieved of the sso-token logged in withfromcod_apiimportAPI# initiating the API classapi=API()## sync# login in with sso tokenapi.login('your_sso_token')# retrieving user identitiesidentities=api.Me.loggedInIdentities()# returns data of type dict# printing results to consoleprint(identities)## async# in an async functionasyncdefexample():# login in with sso tokenawaitapi.loginAsync('your_sso_token')# retrieving user identitiesidentities=awaitapi.Me.loggedInIdentitiesAsync()# returns data of type dict# printing results to consoleprint(identities)# CALL THE example FUNCTION IN AN ASYNC ENVIRONMENTUser COD PointsUsing the methodscodPoints()for sync environments andcodPointsAsync()for async environments, in sub classMeofAPIuser’s cod points can be retrieved of the sso-token logged in withfromcod_apiimportAPI# initiating the API classapi=API()## sync# login in with sso tokenapi.login('your_sso_token')# retrieving user cod pointscp=api.Me.codPoints()# returns data of type dict# printing results to consoleprint(cp)## async# in an async functionasyncdefexample():# login in with sso tokenawaitapi.loginAsync('your_sso_token')# retrieving user cod pointscp=awaitapi.Me.codPointsAsync()# returns data of type dict# printing results to consoleprint(cp)# CALL THE example FUNCTION IN AN ASYNC ENVIRONMENTUser AccountsUsing the methodsconnectedAccounts()for sync environments andconnectedAccountsAsync()for async environments,
in sub classMeofAPIuser’s connected accounts can be retrieved of the sso-token logged in withfromcod_apiimportAPI# initiating the API classapi=API()## sync# login in with sso tokenapi.login('your_sso_token')# retrieving user connected accountsaccounts=api.Me.connectedAccounts()# returns data of type dict# printing results to consoleprint(accounts)## async# in an async functionasyncdefexample():# login in with sso tokenawaitapi.loginAsync('your_sso_token')# retrieving user connected accountsaccounts=awaitapi.Me.connectedAccountsAsync()# returns data of type dict# printing results to consoleprint(accounts)# CALL THE example FUNCTION IN AN ASYNC ENVIRONMENTUser settingsUsing the methodssettings()for sync environments andsettingsAsync()for async environments, in sub classMeofAPIuser’s settings can be retrieved of the sso-token logged in withfromcod_apiimportAPI# initiating the API classapi=API()## sync# login in with sso tokenapi.login('your_sso_token')# retrieving user settingssettings=api.Me.settings()# returns data of type dict# printing results to consoleprint(settings)## async# in an async functionasyncdefexample():# login in with sso tokenawaitapi.loginAsync('your_sso_token')# retrieving user settingssettings=awaitapi.Me.settingsAsync()# returns data of type dict# printing results to consoleprint(settings)# CALL THE example FUNCTION IN AN ASYNC ENVIRONMENTDonateDonate Todo LodoDonate Engineer152Donate Werseter