Pyogame2
lib for the popular browsergame ogame
Install / Use
/learn @PiecePaperCode/Pyogame2README
pyogame2
![]()
OGame is a browser-based, money-management and space-war themed massively multiplayer online browser game with over two million accounts.
This lib is supposed to help write scripts and bots for your needs.
it supports ogame_version: 7.2.1
version 12
install
<pre> pip install pyogame2 </pre>update
<pre> pip uninstall pyogame2 pip install pyogame2 </pre>dont want to wait for new updates download direct from the develop branch
<pre> pip install git+https://github.com/PiecePaperCode/pyogame2.git@develop </pre>get started
Discord
functions
login
<pre> from pyogame2 import OGame2 from pyogame2.constants import destination, coordinates, ships, mission, speed, buildings, status empire = OGame2(UNI, USER, PASSWORD) #optional empire = OGame2(UNI, USER, PASSWORD, user_agent='NCSA_Mosaic/2.0 (Windows 3.1)', proxy='https://proxy.com:port') </pre>Want to use it with tor? Tutorial
get attacked
<pre> empire.attacked() returns bool </pre>get neutral
<pre> empire.neutral() returns bool </pre>get speed (universe)
<pre> empire.speed() returns class empire.speed().universe empire.speed().fleet </pre>get planet id's
<pre> empire.planet_ids() returns list empire.id_by_planet_name('name') returns int empire.planet_names() returns list </pre>get moon id's
<pre> empire.moon_ids() returns list **keep in mind to prefer planets id's moon id dont works on every function** </pre>coordinates
<pre> coordinates have the format [galaxy, system, position, destination] destination is referred to planet moon or debris on that coordinate planet=1 debris=2 moon=3 for example [1,200,16,3] = galaxy=1, system=200, position=16, destination=3 for moon with from pyogame2.constants import destination the process is much more readable. when you dont give it an destination it will default to planet returns list </pre>from pyogame2.constants import coordinates, destination
pos = coordinates(galaxy=1,
system=2,
position=12,
dest=destination.debris)
coordinates(1, 2, 12, destination.moon)
coordinates(1, 2, 12, destination.debris)
coordinates(1, 2, 12, destination.planet) or coordinates(1, 2, 12)
get celestial coordinates
works with planet's and moon's
<pre> empire.celestial_coordinates(id) returns list </pre>resources
<pre> resources have the format [metal, crystal, deuterium] darkmatter & energy are irrelevant, because you cant transport these. It is used for transport and market functions from pyogame2.constants import resources res = resources(metal=1, crystal=2, deuterium=3) [1, 2, 3] </pre>get resources
<pre> empire.resources(id) returns class(object) res = empire.resources(id) res.resources returns resources res.day_production returns resources res.darkmatter returns int res.energy returns int res.metal returns int res.crystal returns int res.deuterium returns int </pre>get supply
<pre> empire.supply(id) returns class(object) sup = empire.supply(id) sup.metal_mine.level returns int sup.metal_mine.is_possible returns bool (possible to build) sup.metal_mine.in_construction returns bool sup.metal_mine.cost returns resources sup.crystal_mine sup.deuterium_mine sup.solar_plant sup.fusion_plant sup.metal_storage sup.crystal_storage sup.deuterium_storage returns class(object) </pre>get facilities
<pre> empire.facilities(id) returns class(object) fac = empire.facilities(id) fac.robotics_factory.level returns int fac.robotics_factory.is_possible returns bool (possible to build) fac.robotics_factory.in_construction returns bool fac.robotics_factory.cost returns resources fac.shipyard fac.research_laboratory fac.alliance_depot fac.missile_silo fac.nanite_factory fac.terraformer fac.repair_dock </pre>get moon facilities
<pre> empire.moon_facilities(id) returns class(object) fac = empire.moon_facilities(id) fac.robotics_factory.level returns int fac.robotics_factory.is_possible returns bool (possible to build) fac.robotics_factory.in_construction returns bool fac.robotics_factory.cost returns resources fac.shipyard fac.moon_base fac.sensor_phalanx fac.jump_gate </pre>get marketplace
<pre> Use this function to get all offerings from the market. resourses will be returned in the resourse's format ships will be returned in the ship's format </pre>for bid in empire.marketplace(id, page_nr):
if bid.is_ships:
print(bid.id, bid.offer, bid.price)
print(ships.ship_name(bid.offer), ships.ship_amount(bid.offer))
if bid.is_resources:
print(bid.id, bid.offer, bid.price)
print(bid.is_possible)
>>>1234 (204, '508', 'shipyard') [0, '1500000', 0]
>>>light_fighter 508
>>>True
>>>1235 ['10000000', 0, 0] [0, '8000000', 0]
>>>False
buy marketplace
<pre> empire.buy_marketplace(bid.id, id) returns bool </pre>submit marketplace
<pre> you can sell resources and ships. Note that you can sell one ship or one resources at at time. run a for loop if you wanna stack offerings. If the Market accepts your offer depends on your price and availability on your id_planet range cant be 0 </pre> <pre> empire.submit_marketplace(offer, price, id, range) returns bool empire.submit_marketplace(offer=resources(metal=100), price=resources(crystal=50), id=id, range=10) empire.submit_marketplace(offer=ships.large_transporter(10), price=resources(crystal=96000), id=id, range=10) </pre>collect marketplace
<pre> it will collect all your orders at once that are not collected yet buy & sell orders </pre> <pre> empire.collect_marketplace() returns None (Ogame doesnt return a json return message anymore) </pre>get traider
<pre> empire.traider(id) returns Exception("function not implemented yet PLS contribute") </pre>get research
<pre> empire.research() returns class(object) res = empire.research() res.energy res.laser res.ion res.hyperspace res.plasma res.combustion_drive res.impulse_drive res.hyperspace_drive res.espionage res.computer res.astrophysics res.research_network res.graviton res.weapons res.shielding res.armor </pre>get ships
<pre> empire.ships(id) returns class(object) shi = empire.ships(id) shi.light_fighter shi.heavy_fighter shi.cruiser shi.battleship shi.interceptor shi.bomber shi.destroyer shi.deathstar shi.reaper shi.explorer shi.small_transporter shi.large_transporter shi.colonyShip shi.recycler shi.espionage_probe shi.solarSatellite shi.crawler </pre>get defences
<pre> empire.defences(id) returns class(object) def = empire.defences(id) def.rocket_launcher def.laser_cannon_light def.laser_cannon_heavy def.gauss_cannon def.ion_cannon def.plasma_cannon def.shield_dome_small def.shield_dome_large def.missile_interceptor def.missile_interplanetary </pre>get galaxy
<pre> empire.galaxy(coordinates) returns list of class(object) </pre>for planet in empire.galaxy(coordinates(randint(1,6), randint(1,499))):
print(planet.list)
print(planet.name, planet.position, planet.player, planet.player_id, planet.status, planet.moon)
if status.inactive in planet.status:
#Farm Inactive
get ally
<pre> empire.ally() returns string </pre>get officers
<pre> empire.officers() returns Exception("function not implemented yet PLS contribute") </pre>get shop
<pre> empire.shop() returns Exception("function not implemented yet PLS contribute") </pre>get fleet
<pre> empire.fleet() returns list of class(object) </pre>for fleet in empire.fleet():
if fleet.mission == mission.expedition:
print(fleet.list)
print(fleet.id, fleet.mission, fleet.returns, fleet.arrival, fleet.origin, fleet.destination)
get phalanx
<pre> empire.phalanx(coordinates, id) returns list of class(object) </pre>for fleet in empire.phalanx(moon_id, coordinates(2, 410, 7)):
if fleet.mission == mission.expedition:
print(fleet.list)
print(fleet.id, fleet.mission, fleet.returns, fleet.arrival, fleet.origin, fleet.destination)
get spyreports
<pre> empire.spyreports() returns list of class(object) </pre>for spyreport in empire.spyreports():
print(spyreport.id, spyreport.time, spyreport.coordinates,
spyreport.resources, spyreport.technology, spyreport.list)
# you need to check bacause somtimes spymissions fail
if buildings.metal_mine in spyreports.technology:
print(spyreport.technology[buildings.metal_mine])
send fleet
from pyogame2.constants import coordinates, ships, mission, speed
empire.send_fleet(mission=mission.expedition,
id=id,
where=coordinates(1, 12, 16),
ships=[ships.small_transporter(1), shi
Related Skills
node-connect
337.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
337.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.2kCommit, push, and open a PR
