---title: Exporting Room Session Dataslug: /guides/how-to-pull-video-room-session-datasidebar_position: 12x-custom: ported_from_readme: true needs_review: true---This code snippet shows how you can easily use the [List Room Sessions](pathname:///rest/list-room-sessions) endpoint of [SignalWires Video API](pathname:///rest/) to pull all of the activity sessions within each room. Full code example: List Video Room Session Activitypythonimport pandas as pdimport requestsfrom requests.auth import HTTPBasicAuthSpaceURL = example.signalwire.comprojectID = authToken = url = fhttps://{SpaceURL}/api/video/room_sessions?page_size=1000payload={}headers = {}response = requests.request(GET, url, headers=headers, data=payload, auth=HTTPBasicAuth(projectID, authToken)).json()roomSessions = response[data]while next in response[links].keys(): response = requests.get(response[links][next], auth=HTTPBasicAuth(projectID, authToken)).json() roomSessions.extend(response[data])d = []for session in roomSessions: d.append((session[id], session[name], session[start_time], session[end_time], session[duration], session[cost_in_dollars]))df = pd.DataFrame(d, columns=(Room ID, Name, Start Time, End Time, Duration (seconds), Cost in Dollars))print(df.to_string())print(fThere were {len(df)} total room sessions with a total duration of {round((df[Duration (seconds)].sum())/60, 2)} minutes and a total cost of {${:,.2f}.format(df[Cost in Dollars].sum())} dollars.)df.to_csv(RoomSessionData.csv, index=False, encoding=utf-8)Check out our handy **Try It** feature in our docs by replacing the variables here with your own and running it in the browser. You can then easily copy the generated code in cURL or your favorite language! What do I need to run this code?--------------------------------Required Libraries: - [pandas](https://pandas.pydata.org/) - [requests](https://pypi.org/project/requests/) - [HTTPBasicAuth](https://requests.readthedocs.io/en/latest/user/authentication/#basic-authentication) (which is technically a branch off of the requests library above)The API also requires that you authenticate yourself using your Project ID, API Token, and Space URL. If you do not know where to find these values, check out our guide [here](/guides/navigating-your-space#api)!List Room Sessions Code Walkthrough-----------------------------------Despite how quickly this code can pull all your video room session data and format it in a readable way for you, its quite simple! We will start by importing the required libraries and defining our authentication variables. pythonimport pandas as pdimport requestsfrom requests.auth import HTTPBasicAuth# assign auth variablesSpaceURL = example.signalwire.comprojectID = authToken = Next, we will create a request to the room sessions endpoint using the Python requests library using HTTPBasicAuth for authentication, storing the data array of the JSON response in roomSessions.python# define URL, payload, and headers for API Endpointurl = fhttps://{SpaceURL}/api/video/room_sessions?page_size=1000payload={}headers = {}response = requests.request(GET, url, headers=headers, data=payload, auth=HTTPBasicAuth(projectID, authToken)).json()roomSessions = response[data]However, as shown with the page_size in the URL defined above, this will only return 1000 session objects. Its important to make sure you add pagination in whatever language you choose to use to make sure that you end up with only a subset of the full data.pythonwhile next in response[links].keys(): response = requests.get(response[links][next], auth=HTTPBasicAuth(projectID, authToken)).json() roomSessions.extend(response[data])Next, we will loop through each room session object and store the data that we want to export in an array. In this example, we track session ID, room name, start_time, end_time, duration, and cost. However, you could access any of the objects returned in the data array of the API response. To see all of your options, go to the [list room sessions](pathname:///rest/list-room-sessions) endpoint and click the 200 OK under Response. This will populate a full list of all the returned data! python# Sets up an empty arrayd = []# loop through sessionsfor session in roomSessions: d.append((session[id], session[name], session[start_time], session[end_time], session[duration], session[cost_in_dollars]))Lastly, we will use Pandas to create a dataframe with the array above and export to CSV. We will also print some helpful summary stats that tell us the total number of room sessions, total duration of minutes, and total cost in dollars. pythondf = pd.DataFrame(d, columns=(Room ID, Name, Start Time, End Time, Duration (seconds), Cost in Dollars))print(df.to_string())print(fThere were {len(df)} total room sessions with a total duration of {round((df[Duration (seconds)].sum())/60, 2)} minutes and a total cost of {${:,.2f}.format(df[Cost in Dollars].sum())} dollars.)df.to_csv(RoomSessionData.csv, index=False, encoding=utf-8)Thats all there is to it - SignalWires collection of simple video REST APIs make for incredibly easy management and administration of your video rooms and sessions.Sign Up Here------------If you would like to test this example out, you can create a SignalWire account and space [here](https://m.signalwire.com/signups/new?s=1).Please feel free to reach out to us on our [Community Slack](https://signalwire.community/) or create a Support ticket if you need guidance!