Data Models API
Data models represent GDELT records and results.
Event Models
Event
Bases: BaseModel
GDELT Event record.
Represents a single event in the GDELT Events database. Events capture who did what to whom, when, where, and how it was reported.
Source code in src/py_gdelt/models/events.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | |
is_conflict
property
Check if event is conflict (quad_class 3 or 4).
Returns:
| Type | Description |
|---|---|
bool
|
True if event is material conflict (3) or verbal conflict (4). |
is_cooperation
property
Check if event is cooperation (quad_class 1 or 2).
Returns:
| Type | Description |
|---|---|
bool
|
True if event is verbal cooperation (1) or material cooperation (2). |
from_raw(raw)
classmethod
Convert internal _RawEvent to public Event model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
_RawEvent
|
Internal _RawEvent dataclass from TAB-delimited parsing. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Event |
Event
|
Public Event model with proper type conversion. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required fields are missing or invalid. |
Source code in src/py_gdelt/models/events.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
Mention
Bases: BaseModel
Mention of a GDELT event in a source.
Represents a single mention of an event in a news article. Each event can have many mentions across different sources and times.
Source code in src/py_gdelt/models/events.py
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 | |
from_raw(raw)
classmethod
Convert internal _RawMention to public Mention model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
_RawMention
|
Internal _RawMention dataclass from TAB-delimited parsing. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Mention |
Mention
|
Public Mention model with proper type conversion. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required fields are missing or invalid. |
Source code in src/py_gdelt/models/events.py
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 | |
Actor
Bases: BaseModel
Actor in a GDELT event.
Represents an entity (person, organization, country, etc.) participating in an event. Uses CAMEO actor codes for classification.
Source code in src/py_gdelt/models/events.py
is_state_actor
property
Check if actor is a state/government actor.
Returns:
| Type | Description |
|---|---|
bool
|
True if actor has a country code but no known group code, |
bool
|
indicating a state-level actor. |
Article Models
Article
Bases: BaseModel
Article from GDELT DOC API.
Represents a news article monitored by GDELT.
Source code in src/py_gdelt/models/articles.py
seen_datetime
property
Parse seendate to datetime.
Returns:
| Type | Description |
|---|---|
datetime | None
|
datetime object or None if parsing fails |
is_english
property
Check if article is in English.
Timeline
Bases: BaseModel
Timeline data from GDELT DOC API.
Contains time series data for article volume.
Source code in src/py_gdelt/models/articles.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
points
property
Alias for timeline for cleaner access.
dates
property
Get list of dates.
values
property
Get list of values.
parse_timeline(v)
classmethod
Parse timeline from various formats.
Handles both flat format and nested series format from timelinevol API: - Flat: [{"date": "...", "value": ...}, ...] - Nested: [{"series": "...", "data": [{"date": "...", "value": ...}]}]
Source code in src/py_gdelt/models/articles.py
to_dict()
to_series()
Convert to date:value mapping.
Useful for quick lookups and plotting.
TimelinePoint
Bases: BaseModel
Single data point in a timeline.
Source code in src/py_gdelt/models/articles.py
parsed_date
property
Parse date string to datetime.
GKG Models
GKGRecord
Bases: BaseModel
GDELT Global Knowledge Graph record.
Represents enriched content analysis of a news article or document, including extracted themes, entities, locations, tone, and other metadata.
Attributes:
| Name | Type | Description |
|---|---|---|
record_id |
str
|
Unique identifier in format "YYYYMMDDHHMMSS-seq" or with "-T" suffix for translated |
date |
datetime
|
Publication date/time |
source_url |
str
|
URL of the source document |
source_name |
str
|
Common name of the source |
source_collection |
int
|
Source collection identifier (1=WEB, 2=Citation, etc.) |
themes |
list[EntityMention]
|
Extracted themes/topics |
persons |
list[EntityMention]
|
Extracted person names |
organizations |
list[EntityMention]
|
Extracted organization names |
locations |
list[Location]
|
Extracted geographic locations |
tone |
ToneScores | None
|
Document tone analysis scores |
gcam |
dict[str, float]
|
GCAM emotional dimension scores as dict |
quotations |
list[Quotation]
|
Extracted quotations (v2.1+ only) |
amounts |
list[Amount]
|
Extracted numerical amounts (v2.1+ only) |
sharing_image |
str | None
|
Primary sharing image URL if any |
all_names |
list[str]
|
All extracted names as flat list |
version |
int
|
GDELT version (1 or 2) |
is_translated |
bool
|
Whether this is a translated document |
original_record_id |
str | None
|
Original record ID if translated |
translation_info |
str | None
|
Translation metadata string |
Source code in src/py_gdelt/models/gkg.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
primary_theme
property
Get the first/primary theme if any.
Returns:
| Type | Description |
|---|---|
str | None
|
The name of the first theme, or None if no themes exist |
has_quotations
property
Check if record has extracted quotations.
Returns:
| Type | Description |
|---|---|
bool
|
True if one or more quotations were extracted |
from_raw(raw)
classmethod
Convert internal _RawGKG to public GKGRecord model.
This method handles parsing the complex delimited fields from GKG v2.1 format: - Themes: semicolon-delimited "theme,offset" pairs - GCAM: semicolon-delimited "key:value" pairs - Quotations: pipe-delimited records with format "offset#length#verb#quote" - Amounts: semicolon-delimited "amount,object,offset" triples - Locations: semicolon-delimited with multiple sub-fields - Tone: comma-separated values
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
_RawGKG
|
Internal _RawGKG dataclass from TSV parsing |
required |
Returns:
| Type | Description |
|---|---|
GKGRecord
|
Validated GKGRecord with all fields parsed and typed |
Source code in src/py_gdelt/models/gkg.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
Quotation
Amount
NGrams Models
NGramRecord
Bases: BaseModel
GDELT NGram 3.0 record.
Represents an n-gram (word or phrase) occurrence in web content, including context and source information.
Source code in src/py_gdelt/models/ngrams.py
context
property
Get full context (pre + ngram + post).
Returns:
| Type | Description |
|---|---|
str
|
Full context string with ngram surrounded by pre and post context |
is_early_in_article
property
Check if ngram appears in first 30% of article.
Returns:
| Type | Description |
|---|---|
bool
|
True if position <= 20 (first 30% of article) |
is_late_in_article
property
Check if ngram appears in last 30% of article.
Returns:
| Type | Description |
|---|---|
bool
|
True if position >= 70 (last 30% of article) |
from_raw(raw)
classmethod
Convert internal _RawNGram to public NGramRecord model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
_RawNGram
|
Internal raw ngram representation with string fields |
required |
Returns:
| Type | Description |
|---|---|
NGramRecord
|
Validated NGramRecord instance |
Raises:
| Type | Description |
|---|---|
ValueError
|
If date parsing or type conversion fails |
Source code in src/py_gdelt/models/ngrams.py
Common Models
Location
Bases: BaseModel
Geographic location from GDELT data.
Source code in src/py_gdelt/models/common.py
has_coordinates
property
Check if location has valid coordinates.
as_tuple()
Return (lat, lon) tuple. Raises ValueError if either is None.
Source code in src/py_gdelt/models/common.py
as_wkt()
Return WKT POINT string for geopandas compatibility.
Returns:
| Type | Description |
|---|---|
str
|
WKT POINT string in format "POINT(lon lat)". |
Raises:
| Type | Description |
|---|---|
ValueError
|
If lat or lon is None. |
Source code in src/py_gdelt/models/common.py
ToneScores
Bases: BaseModel
Tone analysis scores from GDELT.
Source code in src/py_gdelt/models/common.py
EntityMention
Bases: BaseModel
Entity mention from GKG records.
Source code in src/py_gdelt/models/common.py
Result Models
FetchResult
dataclass
Bases: Generic[T]
Result container with partial failure tracking.
Source code in src/py_gdelt/models/common.py
complete
property
True if no requests failed.
partial
property
True if some but not all requests failed.
total_failed
property
Number of failed requests.
__iter__()
FailedRequest
dataclass
Represents a failed request in a partial result.