So the question in the title. At the moment I’m not sure whether to use ‘a’ before ‘photo’ in the following sentence.
…you can get an album or (a) photo by its id.
An article is an adjective. The same general rules apply.
In general, you can omit an adjective when giving a list of items and the same adjective applies to all of them. "In this aisle we have fresh fruit and vegetables" would be understood to mean "fresh fruit and fresh vegetables", not that the fruit is fresh but the vegetables are rotten. Or, "We specialize in clothes for tall men and women" would be understood to mean "tall men and tall women", not tall men but women of any height.
Of course there are cases where it might not be clear. Like if someone said, "For lunch we had hot tea and sandwiches", I wouldn't assume they meant the sandwiches were hot. There's no easy rules, it's context and common sense. And anything said by a salesman or a politician, I'm always cautious about making assumptions.
So all that said, when "a" applies to all elements in a list, you only need specify it on the first. "You can get an album or photo" is understood to mean "an album or a photo". In this case there's pretty much no ambiguity. Suppose the "an" didn't apply to "photo". How would that change the meaning of the sentence? I suppose in some context it could be "an X and the Y", any X but some specific Y. But that wouldn't make sense here.
I would personally go with: you can get an album or a photo by its id. Omitting the indefinite article just because you have already used one with the first noun in the object of the sentence just sounds a bit unnatural.