Package: crossfire
crossfirePython clientcrossfireis a package created to give easier access toFogo Cruzado's datasets, which is a digital collaborative platform of gun shooting occurrences in the metropolitan areas of Rio de Janeiro and Recife.The package facilitates data extraction fromFogo Cruzado's open API.RequirementsPython 3.9 or newerInstall$pipinstallcrossfireIf you want to have access to the data asPandasDataFrames:$pipinstallcrossfire[df]If you want to have access to the data asGeoPandasGeoDataFrames:$pipinstallcrossfire[geodf]AuthenticationTo have access to the API data,registration is required.Theemailandpasswordused in the registration can be configured asFOGOCRUZADO_EMAILandFOGOCRUZADO_PASSWORDenvironment variables in a.envfile:FOGOCRUZADO_EMAIL=your@mail.com
FOGOCRUZADO_PASSWORD=YOUR_PASSWORDIf you prefernotto use these environment variables, you can still use the credentialswhen instantiating a client.UsageList of states covered by the projectGet all states with at least one city covered by the Fogo Cruzado project:fromcrossfireimportstatesstates()It is possible to get results inDataFrae:states(format='df')List of cities covered by the projectGet cities from a specific state covered by the Fogo Cruzado project.fromcrossfireimportcitiescities()It is possible to get results inDataFrae:cities(format='df')CitiesparametersNameRequiredDescriptionTypeDefault valueExamplestate_id❌ID of the statestringNone'b112ffbe-17b3-4ad0-8f2a-2038745d1d14'city_id❌ID of the citystringNone'88959ad9-b2f5-4a33-a8ec-ceff5a572ca5'city_name❌Name of the citystringNone'Rio de Janeiro'format❌Format of the resultstring'dict''dict','df'or'geodf'Listing occurrencesTo get shooting occurrences from Fogo Cruzado dataset it is necessary to specify a state id inid_stateparameter:fromcrossfireimportoccurrencesoccurrences('813ca36b-91e3-4a18-b408-60b27a1942ef')It is possible to get results inDataFrae:occurrences('813ca36b-91e3-4a18-b408-60b27a1942ef',format='df')Or asGeoDataFrame:occurrences('813ca36b-91e3-4a18-b408-60b27a1942ef',format='geodf')OccurrencesparametersNameRequiredDescriptionTypeDefault valueExampleid_state✅ID of the statestringNone'b112ffbe-17b3-4ad0-8f2a-2038745d1d14'id_cities❌ID of the citystring or list of stringsNone'88959ad9-b2f5-4a33-a8ec-ceff5a572ca5'or['88959ad9-b2f5-4a33-a8ec-ceff5a572ca5', '9d7b569c-ec84-4908-96ab-3706ec3bfc57']type_occurrence❌Type of occurrencestring'all''all','withVictim'or'withoutVictim'initial_date❌Initial date of the occurrencesstring,dateordatetimeNone'2020-01-01','2020/01/01','20200101',datetime.datetime(2023, 1, 1)ordatetime.date(2023, 1, 1)final_date❌Final date of the occurrencesstring,dateordatetimeNone'2020-01-01','2020/01/01','20200101',datetime.datetime(2023, 1, 1)ordatetime.date(2023, 1, 1)max_parallel_requests❌Maximum number of parallel requests to the APIint1632format❌Format of the resultstring'dict''dict','df'or'geodf'Custom clientIf not using the environment variables for authentication, it is recommended to use a custom client:fromcrossfireimportClientclient=Client(email="fogo@cruza.do",password="Rio&Pernambuco")# credentials are optional, the default are the environment variablesclient.states()client.cities()client.occurrences('813ca36b-91e3-4a18-b408-60b27a1942ef')Asynchronous use withasynciofromcrossfireimportAsyncClientclient=AsyncClient()# credentials are optional, the default are the environment variablesawaitclient.states()awaitclient.cities()awaitclient.occurrences('813ca36b-91e3-4a18-b408-60b27a1942ef')Credits@FelipeSBarrosis the creator of the Python package. This implementation was funded by CYTED project number520RT0010 redGeoLIBERO.Contributors@sergiospagnuolo@silvadenisson@cuducos