Each authenticated profile includes an optional demographic which can be used to increase the accuracy of any analysis. This data is not collected automatically. Your app can choose to GET or POST this demographic via the Sahha API.
Data Format
All values are optional
String values are case insensitive (for example: 'us' and 'US' are equal and valid).
age : Int
Age must be a valid Int between 1 - 99.
gender : String
Gender must be a valid String from this list:
'male''female''gender diverse'
country : String
Country must be a valid 2 character ISO String from this list:
birthCountry : String
Birth Country must be a valid 2 character ISO String from this list:
ethnicity : String
Any String value.
occupation : String
Any String value.
industry : String
Any String value.
incomeRange : String
Any String value.
education : String
Any String value.
relationship : String
Any String value.
locale : String
Any String value.
livingArrangement : String
Any String value.
birthDate : String
Birth Date must be a String in the format 'YYYY-MM-DD'. For example, '1990-05-20'.
Using the API for Demographics
You can GET or POST demographic info via the API using this model.
// All values are optional
public struct SahhaDemographic: Codable {
public var age: Int?
public var gender: String? // "male", "female", "gender diverse"
public var country: String? // ISO 2 character code, i.e. "us", "uk", "au", etc.
public var birthCountry: String? // ISO 2 character code, i.e. "us", "uk", "au", etc.
public var ethnicity: String? // any string
public var occupation: String? // any string
public var industry: String? // any string
public var incomeRange: String? // any string
public var education: String? // any string
public var relationship: String? // any string
public var locale: String? // any string
public var livingArrangement: String? // any string
public var birthDate: String? // must be in format "YYYY-MM-DD", i.e. "1990-05-20"
} // All values are optional
class SahhaDemographic {
public var age: Int?
public var gender: String? // "male", "female", "gender diverse"
public var country: String? // ISO 2 character code, i.e. "us", "uk", "au", etc.
public var birthCountry: String? // ISO 2 character code, i.e. "us", "uk", "au", etc.
public var ethnicity: String? // any string
public var occupation: String? // any string
public var industry: String? // any string
public var incomeRange: String? // any string
public var education: String? // any string
public var relationship: String? // any string
public var locale: String? // any string
public var livingArrangement: String? // any string
public var birthDate: String? // must be in format "YYYY-MM-DD", i.e. "1990-05-20"
} // All values are optional
var demographic = {
"age" : 35, // int
"gender" : "Female", // string, "Male", "Female", "Gender Diverse"
"country" : "NZ", // ISO 2 digit code, i.e. "US", "UK", "AU", etc.
"birthCountry" : "UK" // ISO 2 digit code, i.e. "US", "UK", "AU", etc.
"birthDate" : "1990-05-20" // must be in format "YYYY-MM-DD", i.e. "1990-05-20"
}; // All values are optional
const demographic = {
age: 35, // number
gender: 'Female', // string, "Male", "Female", "Gender Diverse",
country: 'NZ', // ISO 2 digit code, i.e. "US", "UK", "AU", etc.
birthCountry: 'UK', // ISO 2 digit code, i.e. "US", "UK", "AU", etc.
birthDate: '1990-05-20' // must be in format "YYYY-MM-DD", i.e. "1990-05-20"
}; interface SahhaDemographic {
age?: number; // number
gender?: string; // string, "Male", "Female", "Gender Diverse",
country?: string; // ISO 2 digit code, i.e. "US", "UK", "AU", etc.
birthCountry?: string; // ISO 2 digit code, i.e. "US", "UK", "AU", etc.
ethnicity?: string;
occupation?: string;
industry?: string;
incomeRange?: string;
education?: string;
relationship?: string;
locale?: string;
livingArrangement?: string;
birthDate?: string; // must be in format "YYYY-MM-DD", i.e. "1990-05-20"
} POST
An example POST of demographic info via the SDK.
let demographic = SahhaDemographic(
age: 32,
gender: "Female",
country: "NZ",
birthCountry: "UK",
birthDate: "1990-05-20"
)
Sahha.postDemographic(demographic) { error, success in
if let error = error {
print(error)
}
print(success)
} var demographic = SahhaDemographic(
age: 32,
gender: "Female",
country: "NZ",
birthCountry: "UK",
birthDate: "1990-05-20"
)
Sahha.postDemographic(demographic) { error, success ->
if (error != null) {
println(error)
} else {
println(success.toString())
}
} var demographic = {
"age" : 32, // int
"gender" : "Female", // string, "Male", "Female", "Gender Diverse"
"country" : "NZ", // ISO 2 digit code, i.e. "US", "UK", "AU", etc.
"birthCountry" : "UK" // ISO 2 digit code, i.e. "US", "UK", "AU", etc.
};
SahhaFlutter.postDemographic(demographic)
.then((success) => {
debugPrint(success.toString())
})
.catchError((error, stackTrace) => {
debugPrint(error.toString())
}); const demographic = {
age: 32, // number
gender: "Female", // string, "Male", "Female", "Gender Diverse",
country: "NZ", // ISO 2 digit code, i.e. "US", "UK", "AU", etc.
birthCountry: "UK", // ISO 2 digit code, i.e. "US", "UK", "AU", etc.
birthDate: "1990-05-20" // must be in format "YYYY-MM-DD", i.e. "1990-05-20"
}
Sahha.postDemographic(demographic, (error: string, success: boolean) => {
if error {
console.error(`Error: $ {error}`);
} else if success {
console.log(`Success: $ {success}`);
}
}); Sahha.postDemographic({
demographic: {
gender: 'Female',
age: 25
}
}).then(
function (response) {
console.log(response.success);
},
function (error) {
console.log(error);
}
); GET
An example GET of demographic info via the SDK.
Sahha.getDemographic() { error, demographic in
if let error = error {
print(error)
}
if let demographic = demographic {
print(demographic)
}
} Sahha.getDemographic() { error, demographic ->
if (error != null) {
println(error)
} else if (demographic != null) {
println(demographic)
}
} SahhaFlutter.getDemographic()
.then((value) => {
debugPrint(value)
})
.catchError((error, stackTrace) => {
debugPrint(error.toString())
}); Sahha.getDemographic((error: string, value: string) => {
if error {
console.error(`Error: $ {error}`);
} else if value {
console.log(`Value: $ {value}`);
}
}); Sahha.getDemographic().then(
function (response) {
console.log(response.demographic);
const json = JSON.parse(response.demographic);
},
function (error) {
console.log(error);
}
);