foodAlertsAPI package¶
foodAlertsAPI.Alert¶
-
class
foodAlertsAPI.Alert.
Alert
(dict)¶ Bases:
object
Alert is the base class representing the details of an FSA Food Alert. Optional attributes have value None if unspecified. This applies to all classes.
-
_id
¶ url to alert in the FSA page, same as the alertURL attribute
Type: string
-
_title
¶ Type: string
-
_shortTitle
¶ “None” if the API does not provide this value
Type: string
-
_description
¶ Type: string
-
_created
¶ represents date in ISO format
Type: string
-
_modified
¶ represents datetime in ISO format
Type: string
-
_notation
¶ unique identifier for alert used in the foodAlertsAPI.foodAlertsAPI getAlert() function
Type: string
-
_country
¶ a foodAlertsAPI.Country object. None if unspecified by the API indicating that the alert may apply to any country in the UK
Type: object
-
_status
¶ the alert status, usually “Published”, but in rare cases may be “Withdrawn”
Type: string
-
_type
¶ an array of strings (URLs, one corresponding to the Alert object in the API, and another to the type of alert corresponding to the Alert object (one of “AA” - allergen, “FAFA” - food action, or “PRIN” - product recall))
Type: string[]
-
_actionTaken
¶ description of the action taken, or in the case of FAFAs actions to be taken by enforcement authority
Type: string, optional
-
_consumerAdvice
¶ text giving the advice to consumers
Type: string, optional
-
_SMSText
¶ short description to be used in SMS notifications
Type: string, optional
-
_twitterText
¶ short description to be used in Twitter notifications
Type: string, optional
-
_alertURL
¶ URL for the alert on the FSA web site
Type: dict, optional
-
_shortURL
¶ Type: dict, optional
array of foodAlertsAPI.RelatedMedia objects
Type: object[], optional
-
_problem
¶ array of foodAlertsAPI.Problem objects
Type: object[], optional
-
_productDetails
¶ array of foodAlertsAPI.ProductDetails objects
Type: object[], optional
-
_reportingBusiness
¶ a foodAlertsAPI.Business object
Type: object[], optional
-
_otherBusiness
¶ an array of foodAlertsAPI.Business objects
Type: object[], optional
-
_previousAlert
¶ URL to previous alert. This exists if the Alert is an update to a previous one
Type: string, optional
-
SMStext
()¶ Returns: short description to be used in SMS notifications Return type: SMSText (string, optional)
-
actionTaken
()¶ Returns: description of the action taken, or in the case of FAFAs actions to be taken by enforcement authority Return type: actionTaken (string, optional)
-
alertURL
()¶ Returns: URL for the alert on the FSA web site Return type: alertURL (string, optional)
-
allergenLabels
()¶ Get the list of allergens in this Alert
Returns: list of allergens as strings Return type: allergens (string[])
-
consumerAdvice
()¶ Returns: text giving the advice to consumers Return type: consumerAdvice (string, optional)
-
country
()¶ Returns: a foodAlertsAPI.Country object. None if unspecified by the API indicating that the alert may apply to any country in the UK Return type: country (object, optional)
-
countryLabel
()¶ Returns: the country that the alerts applies to in string format. None if unspecified Return type: country.label (string, optional)
-
created
()¶ Returns: represents date in ISO format Return type: created (string)
-
description
()¶ Returns: alert description. None if the API does not provide this value Return type: description (string, optional)
-
id
()¶ Returns: url to alert in the FSA page, same as the alertURL attribute. Return type: id (string)
-
modified
()¶ Returns: represents datetime in ISO format Return type: modified (string)
-
notation
()¶ Returns: unique identifier for alert used in the foodAlertsAPI.foodAlertsAPI getAlert() function Return type: notation (string)
-
otherBusiness
()¶ Returns: an array of foodAlertsAPI.Business objects Return type: otherBusiness (object[], optional)
-
pathogenRiskLabels
()¶ Get the list of pathogen risks in this Alert
Returns: list of pathogen risks as strings Return type: pathogenRisks (string[])
-
previousAlert
()¶ Returns: a foodAlertsAPI.Alert object Return type: previousAlert (object, optional)
-
problem
()¶ Returns: array of foodAlertsAPI.Problem objects Return type: problem (object[], optional)
-
productDetails
()¶ Returns: array of foodAlertsAPI.ProductDetails objects Return type: productDetails (object[], optional)
Returns: array of foodAlertsAPI.RelatedMedia objects Return type: relatedMedia (object[], optional)
-
reportingBusiness
()¶ Returns: common name for the reporting business Return type: reportingBusiness (string, optional)
-
shortTitle
()¶ Returns: compact version of title. None if the API does not provide this value Return type: shortTitle (string, optional)
-
shortURL
()¶ Returns: short URL to alert used in SMS and twitter texts Return type: shortURL (string, optional)
-
status
()¶ Returns: the alert status in string format Return type: status (string)
-
title
()¶ Returns: alert title Return type: title (string)
-
twitterText
()¶ Returns: short description to be used in Twitter notifications Return type: twitterText (string, optional)
-
type
()¶ Returns: one of “AA”, “FAFA”, or “PRIN” Return type: type (string)
-
foodAlertsAPI.Allergen¶
-
class
foodAlertsAPI.Allergen.
Allergen
(dict)¶ Bases:
object
Array of allergens drawn from the controlled list of allergens. For an Allergen Alert there will also be at least one allergen present on the problem statement.
-
_label
¶ name for the allergen
Type: string
-
_notation
¶ a unique identifier for the allergen
Type: string
-
_riskStatement
¶ text describing the risk from the allergen
Type: string
-
label
()¶ Returns: the allergen name Return type: label (string)
-
notation
()¶ Returns: unique identifier for the allergen Return type: notation (string, optional)
-
riskStatement
()¶ Returns: text describing the risk from the allergen Return type: riskStatement (string)
-
foodAlertsAPI.BatchDescription¶
-
class
foodAlertsAPI.BatchDescription.
BatchDescription
(dict)¶ Bases:
object
-
_bestBeforeDescription
¶ “best before” date range for the batch
Type: string, optional
-
_bestBeforeDate
¶ “best before” date (or dates) for the batch
Type: string, optional
-
_useByDescription
¶ “use by” date range for the batch
Type: string, optional
-
_useByDate
¶ “use by” date (or dates) for the batch
Type: string, optional
-
_batchCode
¶ batch number or code for the batch
Type: string, optional
-
_lotNumber
¶ lot number for the batch
Type: string, optional
-
_batchTextDescription
¶ other textual description for the batch
Type: string, optional
-
batchCode
()¶ Returns: batch number or code for the batch Return type: batchCode (string, optional)
-
batchTextDescription
()¶ Returns: other textual description for the batch Return type: batchTextDescription (string, optional)
-
bestBeforeDate
()¶ Returns: “best before” date (or dates) for the batch Return type: bestBeforeDate (string, optional)
-
bestBeforeDescription
()¶ Returns: “best before” date range for the batch Return type: bestBeforeDescription (string, optional)
-
lotNumber
()¶ Returns: lot number for the batch Return type: lotNumber (string, optional)
-
useByDate
()¶ Returns: “use by” date (or dates) for the batch Return type: useByDate (string, optional)
-
useByDescription
()¶ Returns: “use by” date range for the batch Return type: useByDescription (string, optional)
-
foodAlertsAPI.Business¶
-
class
foodAlertsAPI.Business.
Business
(dict)¶ Bases:
object
-
_commonName
¶ name by which the organisation is commonly known
Type: string
-
_identifier
¶ unique identifier for the organisation
Type: string, optional
-
_legalName
¶ legal (registered) name of the organisation
Type: string, optional
-
commonName
()¶ Returns: name by which the organisation is commonly known Return type: commonName (string)
-
identifier
()¶ Returns: unique identifier for the organisation Return type: identifier (string, optional)
-
legalName
()¶ Returns: legal (registered) name of the organisation Return type: legalName (string, optional)
-
foodAlertsAPI.Country¶
foodAlertsAPI.HazardCategory¶
-
class
foodAlertsAPI.HazardCategory.
HazardCategory
¶ Bases:
object
Classifies the problem as into one of the hazard categories. This information is useful for analysis and retrieval but does not directly affect the default textual presentation of the alert. Support for this field is under discussion.
-
_label
¶ name for the hazard category
Type: string
-
_notation
¶ unique identifier for the hazard category
Type: string
-
-
foodAlertsAPI.HazardCategory.
label
(self)¶ Returns: name for the hazard category Return type: label (string)
-
foodAlertsAPI.HazardCategory.
notation
(self)¶ Returns: unique identifier for the hazard category Return type: notation (string)
foodAlertsAPI.PathogenRisk¶
-
class
foodAlertsAPI.PathogenRisk.
PathogenRisk
(dict)¶ Bases:
object
Classifies the problem as being due to actual or possible contamination with a pathogen.
-
_label
¶ name for the pathogen risk
Type: string
-
_notation
¶ unique identifier for the pathogen risk
Type: string
-
_pathogen
¶ URL to page of the pathogen involved
Type: string
-
_riskStatement
¶ text describing the risk from this pathogen, or possible pathogen
Type: string
-
label
()¶ Returns: name for the pathogen risk Return type: label (string)
-
notation
()¶ Returns: unique identifier for the pathogen risk Return type: notation (string)
-
pathogen
()¶ Returns: indicates the actual pathogen involved. The PathogenRisk may represent actual or possible contamination with this pathogen Return type: pathogen (object)
-
riskStatement
()¶ Returns: text describing the risk from this pathogen, or possible pathogen Return type: riskStatement (string)
-
foodAlertsAPI.Problem¶
-
class
foodAlertsAPI.Problem.
Problem
(dict)¶ Bases:
object
-
_riskStatement
¶ text describing the problem in terms of the risk to consumers
Type: string
-
_allergen
¶ a list of foodAlertsAPI.Allergen objects
Type: object[]
-
_hazardCategory
¶ a foodAlertsAPI.HazardCategory object. Classifies the problem as into one of the hazard categories. Support for this field is under discussion.
Type: object, optional
-
_pathogenRisk
¶ classifies the problem as being due to actual or possible contamination with a pathogen.
Type: object, optional
-
_reason
¶ a foodAlertsAPI.Reason object
Type: object, optional
-
allergen
()¶ Returns: a list of foodAlertsAPI.Allergen objects Return type: allergen (object[])
-
allergenLabels
()¶ Returns: list of allergens in string format Return type: allergenLabels (string[], optional)
-
hazardCategory
()¶ Returns: - a foodAlertsAPI.HazardCategory object. Classifies the problem as into one of the hazard categories.
- Support for this field is under discussion.
Return type: hazardCategory (object, optional)
-
hazardCategoryLabel
()¶ Returns: hazard category in string format Return type: hazardCategoryLabel (string, optional)
-
hazardCategoryNotation
()¶ Returns: unique identifier for hazard category in string format Return type: hazardCategoryNotation (string, optional)
-
pathogenRisk
()¶ Returns: classifies the problem as being due to actual or possible contamination with a pathogen. Return type: pathogenRisk (object, optional)
-
pathogenRiskLabels
()¶ Returns: pathogen risks in string format Return type: pathogenRiskLabels (string[], optional)
-
reason
()¶ Returns: a foodAlertsAPI.Reason object Return type: reason (object, optional)
-
riskStatement
()¶ Returns: text describing the problem in terms of the risk to consumers Return type: riskStatement (string)
-
foodAlertsAPI.ProductCategory¶
-
class
foodAlertsAPI.ProductCategory.
ProductCategory
(dict)¶ Bases:
object
foodAlertsAPI.ProductDetails¶
-
class
foodAlertsAPI.ProductDetails.
ProductDetails
(dict)¶ Bases:
object
-
_productName
¶ name of the affected product
Type: string
-
_productCode
¶ identifying code for the affected product
Type: string, optional
-
_packSizeDescription
¶ description of the package size affected - may be weight, volume or other description
Type: string, optional
-
_allergen
¶ list of urls to the allergens present in the product
Type: string[], optional
-
_batchDescription
¶ an array of foodAlertsAPI.BatchDescription objects
Type: object[]
-
_productCategory
¶ a foodAlertsAPI.ProductCategory object. Identifies the category of the affected product. This information is used to support search and analysis and does not need to be separately included in the alert presentation.
Type: object, optional
-
allergen
()¶ Returns: list of urls to the allergens present in the product Return type: allergen (string[])
-
batchDescription
()¶ Returns: an array of foodAlertsAPI.BatchDescription objects Return type: batchDescription (object[])
-
packSizeDescription
()¶ Returns: description of the package size affected - may be weight, volume or other description Return type: packSizeDescription (string, optional)
-
productCategory
()¶ Returns: - a foodAlertsAPI.ProductCategory object. Identifies the category of the affected product.
- This information is used to support search and analysis and does not need to be separately included in the alert presentation.
Return type: productCategory (object, optional)
-
productCode
()¶ Returns: identifying code for the affected product Return type: productCode (string, optional)
-
productName
()¶ Returns: name of the affected product Return type: productName (string)
-
foodAlertsAPI.Reason¶
-
class
foodAlertsAPI.Reason.
Reason
¶ Bases:
object
Classifies the reason for the problem as being one of a standard set of reasons. This information is useful for analysis and retrieval but does not directly affect the default textual presentation of the alert. Support for this field is under discussion.
-
_label
¶ name for the reason
Type: string
-
_notation
¶ unique identifier for the reason
Type: string
-
label
()¶ Returns: name for the reason Return type: label (string)
-
notation
()¶ Returns: unique identifier for the reason Return type: notation (string)
-
foodAlertsAPI.RelatedMedia¶
-
class
foodAlertsAPI.RelatedMedia.
RelatedMedia
(dict)¶ Bases:
object
-
_id
¶ URL for the related media
Type: string
-
_title
¶ title for the related media
Type: string, optional
-
id
()¶ Returns: URL for the related media Return type: id (string)
-
title
()¶ Returns: title for the related media Return type: title (string, optional)
-
foodAlertsAPI.Status¶
-
class
foodAlertsAPI.Status.
Status
(dict)¶ Bases:
object
-
_id
¶ URL for the status
Type: string
-
_label
¶ name of the status of the Alert, normally this will be ‘Published’ but in rare cases may be changed to ‘Withdrawn’
Type: string
-
id
()¶ Returns: URL for the status Return type: id (string)
-
label
()¶ Returns: name of the status of the Alert, normally this will be ‘Published’ but in rare cases may be changed to ‘Withdrawn’ Return type: label (string, optional)
-
foodAlertsAPI.foodAlertsAPI¶
-
class
foodAlertsAPI.foodAlertsAPI.
foodAlertsAPI
¶ Bases:
object
-
getAlert
(ID)¶ Get a specific alert based on its notation, e.g. (FSA-AA-01-2018)
Parameters: ID (string) – the alert ID Returns: A foodAlertsAPI.Alert object Raises: ValueError
– occurs when an invalid value for the notation is provided
-
getAlerts
(quantifier=None, detailed=False, limit=None, offset=None, sortBy=None, filters={})¶ Gets alerts from the FSA Food Alerts API
Parameters: - quantifier – the quantifier can be an int n, in which case the function returns the last n alerts. The quantifier can also be a date string in ISO format, in which case the function returns the alerts published since the given date
- detailed (bool, optional) – determines whether the Alert objects returned will contain all properties. When this is set to false, only the summary properties are included. Defaults to False if unspecified
- limit (int, optional) – specifies the maximum number of Alert objects that can be returned
- offset (int, optional) – return the list of items starting with the nth item, together with limit this enables paging through a long set of results
- sortBy (string, optional) – reorder the list of results in ascending order of the given property (or property chain). To sort in descending order use sortBy=-prop. More than one sort can be included in which case they will be applied in order
- filters (dict, optional) – filters based on alert object properties, e.g. {“type”:”AA”}
Returns: A list of foodAlertsAPI.Alert objects
Raises: ValueError
– occurs when an invalid value for the quantifier or optional arguments is provided
-
searchAlerts
(query, detailed=False, limit=None, offset=None, sortBy=None, filters={})¶ Search for query in alerts from the FSA Food Alerts API
Parameters: - query (string) – the search query
- detailed (bool, optional) – determines whether the Alert objects returned will contain all properties. When this is set to false, only the summary properties are included. Defaults to False if unspecified
- limit (int, optional) – specifies the maximum number of Alert objects that can be returned
- offset (int, optional) – return the list of items starting with the nth item, together with limit this enables paging through a long set of results
- sortBy (string, optional) – reorder the list of results in ascending order of the given property (or property chain). To sort in descending order use sortBy=-prop. More than one sort can be included in which case they will be applied in order
- filters (dict, optional) – filters based on alert object properties, e.g. {“type”:”AA”}
Returns: A list of foodAlertsAPI.Alert objects
Raises: ValueError
– occurs when an invalid value for the query or optional arguments is provided
-