Is there an API call where you can get all achievements and all unread achievements?
Like this:
Update
Thanks to the answer of Glorfindel, I use the following methods to calculate the unread achievements.
Note: I'm using angular 8
notification.service.ts
public getAchievements(options?: IQuestionOptions): Observable<IResponse> {
const headers = new HttpHeaders()
.set('Accept', '*/*');
const params = new HttpParams()
.set('key', {{APP_KEY}})
.set('access_token', {{TOKEN}})
.set('pageSize', '30')
.set('page', '1')
.set('filter', 'O5lYbEN2lExNfdp2Q');
return this.http
.get<IResponse>(
'https://api.stackexchange.com/2.3/',
{ headers, params }
);
}
Counting unread items
public countUnread(items: any): number {
if (!items) {
return 0;
}
return items
.map(item => item.is_unread ?
item.reputation_change ?
item.reputation_change
: 1
: 0)
.reduce((accumulator, currentValue) => accumulator + currentValue);
}
Also to be mentioned is that this method is used for counting unread messages and unread achievements, depending on what was handed over.