Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products.

Python 3.10 is now generally available.

Module: google.appengine.api.datastore_types

Stay organized with collections Save and categorize content based on your preferences.

Higher-level, semantic data types for the datastore.

These types are expected to be set as attributes of Entities.

Most of these types are based on XML elements from Atom and GData elements from the atom and gd namespaces. For more information, see:


The namespace schemas are:



class Blob: A blob type, appropriate for storing binary data of any length.

class BlobKey: Key used to identify a blob in Blobstore.

class ByteString: A byte-string type, appropriate for storing short amounts of indexed data.

class Category: A tag, ie a descriptive word or phrase. Entities may be tagged by users,

class Email: An RFC2822 email address. Makes no attempt at validation.

class EmbeddedEntity: A proto encoded EntityProto.

class GeoPt: A geographical point, specified by floating-point latitude and longitude

class IM: An instant messaging handle. Includes both an address and its protocol.

class Key: The primary key for a datastore entity.

class Link: A fully qualified URL. Usually http: scheme, but may also be file:, ftp:,

class PhoneNumber: A human-readable phone number or address.

class PostalAddress: A human-readable mailing address. Again, mailing address formats vary

class Rating: A user-provided integer rating for a piece of content. Normalized to a

class Text: A long string type.

class UtcTzinfo: Abstract base class for time zone info objects.


DatetimeToTimestamp(...): Converts a datetime.datetime to microseconds since the epoch, as a float.

DecodeAppIdNamespace(...): Decodes app_namespace_str into an (app_id, namespace) pair.

EncodeAppIdNamespace(...): Concatenates the application ID and namespace into a single string.

FromPropertyPb(...): Converts a property PB to a python value.

FromPropertyTypeName(...): Returns the python type given a type name.

FromReferenceProperty(...): Converts a reference PropertyValue to a Key.

GetPropertyValueTag(...): Returns the tag constant associated with the given entity_pb2.PropertyValue.

PackBlob(...): Packs a Blob property into a entity_pb2.PropertyValue.

PackBool(...): Packs a boolean property into an entity_pb2.PropertyValue.

PackDatetime(...): Packs a datetime-typed property into a entity_pb2.PropertyValue.

PackFloat(...): Packs a float property into a entity_pb2.PropertyValue.

PackGeoPt(...): Packs a GeoPt property into a entity_pb2.PropertyValue.

PackInteger(...): Packs an integer property into an entity_pb2.PropertyValue.

PackKey(...): Packs a reference property into an entity_pb2.PropertyValue.

PackString(...): Packs a string-typed property into a entity_pb2.PropertyValue.

PackUser(...): Packs a User property into a entity_pb2.PropertyValue.

PartitionString(...): Returns a 3-element tuple containing the part before the separator and the part after the separator.

PropertyTypeName(...): Returns the type name of the given property value, as a string.

PropertyValueFromString(...): Returns an instance of a property value given a type and string value.

PropertyValueToKeyValue(...): Converts an entity_pb2.PropertyValue into a comparable hashable key value.

ReferenceToKeyValue(...): Converts a key into a comparable hashable key value.

ResolveAppId(...): Validates the application ID, providing a default.

ResolveNamespace(...): Validates the app namespace, providing a default.

RestoreFromIndexValue(...): Restores an index value to the correct datastore type.

SetNamespace(...): Sets the namespace for a protocol buffer or clears the field.

ToPropertyPb(...): Creates type-specific entity_pb2.PropertyValues.

ValidateInteger(...): Raises an exception if value is not a valid integer.

ValidateProperty(...): Helper function for validating property values.

ValidatePropertyInteger(...): Raises an exception if the supplied integer is invalid.

ValidatePropertyKey(...): Raises an exception if the supplied datastore.Key instance is invalid.

ValidatePropertyLink(...): Validates the length of an indexed Link property.

ValidatePropertyNothing(...): No-op validation function.

ValidatePropertyString(...): Validates the length of an indexed string property.

ValidateReadProperty(...): Helper function for validating property values.

ValidateString(...): Raises an exception if the value is not a valid string or a subclass thereof.

ValidateStringLength(...): Raises an exception if the supplied string is too long.

typename(...): Returns the type of obj as a string.

RESERVED_PROPERTY_NAME Instance of re.Pattern
UTC Instance of google.appengine.api.datastore_types.UtcTzinfo